body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  background-color: #f5f5f5;
  -webkit-user-select: none;
  user-select: none;
  max-width: 700px;
  margin: 0 auto;
}

h1 {
  text-align: center;
  margin: 10px 0;
  font-size: 24px;
}

#game-container {
  padding-top: 10px;
  width: 100%;
  margin: 0 auto;
  padding: 0 10px;
  box-sizing: border-box;
}

/* Message styles */
.message {
  position: fixed;
  left: 0;
  right: 0;
  top: 5px;
  text-align: center;
  font-weight: bold;
  margin: 0 auto;
  padding: 8px;
  border-radius: 5px;
  display: none;
  font-size: 14px;
  width: 80%;
  max-width: 300px;
  background-color: #f5f5f5;
  border: 1px solid #d3d6da;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Grid styles */
.letter-grid {
  margin: 10px auto;
  width: 100%;
  max-width: 320px;
}

.grid-row {
  display: block;
  text-align: center;
  margin-bottom: 5px;
}

.grid-cell {
  display: inline-block;
  width: 42px;
  height: 42px;
  margin: 0 3px;
  line-height: 42px;
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  border: 2px solid #d3d6da;
  vertical-align: middle;
  text-transform: uppercase;
  background-color: white;
  position: relative;
}

.grid-cell.empty {
  border: 2px solid #d3d6da;
}

.grid-cell.filled {
  border: 2px solid #878a8c;
}

.grid-cell.correct {
  border: 2px solid #888;
  background-color: #777777;
}

.grid-cell.present {
  border: 2px solid #888;
  background-color: #dddddd;
}

.grid-cell.absent {
  border: 2px solid #888;
  background-color: #ffffff;
}

/* Visual indicators for Kindle black and white display */
.correct-indicator {
  position: absolute;
  font-size: 10px;
  margin-left: -18px;
  margin-top: -10px;
}

.present-indicator {
  position: absolute;
  font-size: 10px;
  margin-left: -18px;
  margin-top: -10px;
}

.mini-indicator {
  font-size: 7px;
  vertical-align: top;
  margin-left: 1px;
}

/* Keyboard styles */
.keyboard {
  margin: 15px auto;
  width: 100%;
  max-width: 500px;
  text-align: center;
}

.keyboard-row {
  margin-bottom: 8px;
  text-align: center;
}

.keyboard-key {
  display: inline-block;
  min-width: 30px;
  height: 45px;
  margin: 0 3px 3px 0;
  border-radius: 4px;
  border: 1px solid #d3d6da;
  background-color: #d3d6da;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  vertical-align: middle;
  padding: 0 5px;
}

.keyboard-key.wide-key {
  min-width: 60px;
  font-size: 14px;
}


.keyboard-key.correct {
  background-color: #777777;
  border-color: #888;
}

.keyboard-key.present {
  background-color: #aaaaaa;
  border-color: #888;
}

.keyboard-key.absent {
  background-color: #ffffff;
  border-color: #888;
}

/* Button container */
.button-container {
  margin: 10px auto;
  text-align: center;
}

.button-container button {
  margin: 0 3px 5px;
  padding: 6px 10px;
  border-radius: 3px;
  border: 1px solid #d3d6da;
  background-color: #d3d6da;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
  background-color: #f5f5f5;
  margin: 10% auto;
  padding: 15px;
  border: 1px solid #888;
  width: 85%;
  max-width: 450px;
  position: relative;
}

.close {
  color: #aaa;
  position: absolute;
  top: 5px;
  right: 10px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
}

/* Statistics styles */
.stats-container {
  display: block;
  text-align: center;
  margin: 15px 0;
}

.stat-box {
  display: inline-block;
  width: 22%;
  margin: 0 1%;
  text-align: center;
}

.stat-number {
  font-size: 20px;
  font-weight: bold;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
}

.guess-distribution {
  margin: 15px 0;
}

.guess-row {
  margin: 4px 0;
  height: 18px;
}

.guess-number {
  display: inline-block;
  width: 10%;
  text-align: center;
  font-weight: bold;
  font-size: 14px;
}

.guess-bar-container {
  display: inline-block;
  width: 85%;
  vertical-align: middle;
}

.guess-bar {
  background-color: #888;
  color: #fff;
  padding: 2px 5px;
  text-align: right;
  font-weight: bold;
  height: 18px;
  line-height: 18px;
  box-sizing: border-box;
  min-width: 20px;
  font-size: 12px;
}

/* Footer */
.footer {
  text-align: center;
  margin: 10px 0;
  font-size: 11px;
}
.letter-with-indicator {
  position: relative;
  display: inline-block;
}

.key-with-indicator {
  display: inline-block;
}

.correct-indicator, .present-indicator {
  font-size: 10px;
  position: absolute;
  left: -10px;
  top: -10px;
  font-weight: bold;
}

.mini-indicator {
  font-size: 10px;
  vertical-align: super;
  margin-left: 1px;
  font-weight: bold;
}

.indicator {
  font-size: 10px;
  font-weight: bold;
  position: absolute;
  top: 2px;
  right: 2px;
}

.key-indicator {
  font-size: 8px;
  font-weight: bold;
  vertical-align: super;
  margin-left: 1px;
}

.indicator-key {
  text-align: center;
  margin: 5px auto;
  font-size: 12px;
  max-width: 320px;
  padding: 5px;
  border: 1px solid #d3d6da;
  background-color: #f8f8f8;
  border-radius: 3px;
}

.indicator-key span {
  margin: 0 5px;
  font-weight: bold;
}

@media (max-width: 500px) {
  .grid-cell {
    width: 36px;
    height: 36px;
    line-height: 36px;
    font-size: 20px;
    margin: 0 2px;
  }
  
  .keyboard-key {
    min-width: 28px;
    height: 40px;
    font-size: 14px;
    margin: 0 4px 4px 0;
  }
  
  .keyboard-key.wide-key {
    min-width: 45px;
    font-size: 16px;
  }
}

@media (min-width: 768px) {
  h1 {
    font-size: 32px;
    margin: 20px 0;
  }
  
  .letter-grid {
    max-width: 380px;
  }
  
  .grid-cell {
    width: 50px;
    height: 50px;
    line-height: 50px;
    font-size: 28px;
    margin: 0 4px;
  }
  
  .keyboard {
    max-width: 600px;
    margin: 25px auto;
  }
  
  .keyboard-key {
    min-width: 40px;
    height: 55px;
    font-size: 18px;
    margin: 0 8px 8px 0;
  }
  
  .keyboard-key.wide-key {
    min-width: 70px;
    font-size: 16px;
  }
  
  .indicator-key {
    max-width: 380px;
    font-size: 14px;
    padding: 8px;
  }
  
  .button-container button {
    padding: 8px 16px;
    font-size: 14px;
    margin: 0 6px 8px;
  }
  
  .modal-content {
    max-width: 500px;
    padding: 20px;
  }
  
  .stat-number {
    font-size: 24px;
  }
  
  .stat-label {
    font-size: 13px;
  }
  
  .guess-row {
    height: 22px;
  }
  
  .guess-number {
    font-size: 16px;
  }
  
  .guess-bar {
    height: 22px;
    line-height: 22px;
    font-size: 14px;
  }
  
  .message {
    max-width: 400px;
    font-size: 16px;
    padding: 10px;
  }
  
  .footer {
    font-size: 13px;
    margin: 20px 0;
  }
}

/* Kindle Paperwhite (1072x1448) optimization */
@media (min-width: 1000px) {
  body {
    max-width: 1050px;
    font-size: 22px;
    padding-top: 25px;
  }
  
  h1 {
    font-size: 46px;
    margin: 30px 0;
  }
  
  #game-container {
    padding-top: 15px;
  }
  
  .letter-grid {
    max-width: 580px;
    margin: 30px auto;
  }
  
  .grid-row {
    margin-bottom: 10px;
  }
  
  .grid-cell {
    width: 80px;
    height: 80px; 
    line-height: 80px; 
    font-size: 42px;
    margin: 0 6px;
    border-width: 4px;
  }
  
  .keyboard {
    max-width: 950px;
    margin: 40px auto;  
  }
  
  .keyboard-row {
    margin-bottom: 15px; 
  }
  
  .keyboard-key {
    min-width: 70px;
    height: 75px;  
    font-size: 28px;
    margin: 0 16px 16px 0; 
    border-radius: 8px;
    border-width: 2px;
  }
  
  .keyboard-key.wide-key {
    min-width: 105px;
    font-size: 32px;
  }
  
  .button-container {
    margin: 30px auto;
  }
  
  .button-container button {
    padding: 14px 30px;
    font-size: 24px;
    margin: 0 15px 12px;
    border-radius: 8px;
  }
  
  .indicator-key {
    max-width: 650px;
    font-size: 22px;
    padding: 14px;
    margin: 20px auto; 
  }
  
  .message {
    max-width: 600px;
    font-size: 24px;
    padding: 18px;
    top: 25px;
  }
  
  .modal-content {
    max-width: 800px;
    padding: 35px; 
    margin: 5% auto;
  }
  
  .close {
    font-size: 40px;
    top: 15px;
    right: 25px;
  }
  
  .stat-box {
    width: 22%;
    margin: 0 1%;
  }
  
  .stat-number {
    font-size: 40px; 
  }
  
  .stat-label {
    font-size: 18px; 
  }
  
  .guess-distribution {
    margin: 30px 0;  
  }
  
  .guess-row {
    height: 35px; 
    margin: 10px 0;  
  }
  
  .guess-number {
    font-size: 22px; 
  }
  
  .guess-bar {
    height: 35px;
    line-height: 35px; 
    font-size: 20px; 
  }
  
  .mini-indicator {
    font-size: 16px;  
  }
  
  .correct-indicator,
  .present-indicator {
    font-size: 18px; 
    margin-left: -26px;
    margin-top: -16px;
  }
  
  .footer {
    font-size: 18px; 
    margin: 30px 0; 
    padding-bottom: 20px; 
  }
}

/* Extra large screens */
@media (min-width: 1400px) {
  body {
    max-width: 1200px;
  }
  
  .letter-grid {
    max-width: 550px;
  }
  
  .grid-cell {
    width: 75px;
    height: 75px;
    line-height: 75px;
    font-size: 40px;
  }
  
  .keyboard {
    max-width: 950px;
  }
  
  .keyboard-key {
    min-width: 70px;
    height: 80px;
    font-size: 28px;
  }
  
  .keyboard-key.wide-key {
    min-width: 140px;
    font-size: 32px;
  }
  
  .indicator-key {
    max-width: 650px;
    font-size: 20px;
  }
  
  .modal-content {
    max-width: 800px;
  }
}