@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap');

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  background: #f7f7f7;
  font-family: 'Montserrat', Arial, sans-serif;
  min-height: 100vh;
  min-width: 100vw;
  margin: 0;
  padding: 0;
  /* Perfect vertical centering */
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-container {
  background: #222;
  color: #fff;
  border-radius: 22px;
  padding: 3rem 3rem 2.5rem 3rem;
  box-shadow: 0 4px 40px rgba(0,0,0,0.22);
  width: 520px;
  min-height: 420px;
  text-align: center;
  position: relative;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.input-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1.3rem;
}

input[type="number"] {
  padding: 0.7rem;
  font-size: 1.18rem;
  border: none;
  border-radius: 9px;
  width: 220px;
  max-width: 100%;
  background: #333;
  color: #fff;
  transition: border 0.2s;
  letter-spacing: 0.2px;
}

input[type="number"]:focus {
  outline: 2px solid #00e6e6;
  outline-offset: 2px;
}

button {
  padding: 0.6rem 1.6rem;
  font-size: 1.13rem;
  border: none;
  border-radius: 9px;
  background: #444;
  color: #fff;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: background 0.2s, box-shadow 0.2s;
}

button:focus {
  outline: 2px solid #00e6e6;
  outline-offset: 2px;
  box-shadow: 0 0 2px #00e6e6;
}

button:hover, .info-btn:hover {
  background: #666;
}

#theme-toggle {
  position: absolute;
  top: 20px;
  right: 30px;
  z-index: 2;
  font-size: 1.4rem;
  padding: 0.38rem 0.9rem;
  background: #444;
  border-radius: 8px;
  transition: background 0.2s;
}

.message {
  min-height: 2.2rem;
  margin-bottom: 0.4rem;
  opacity: 0;
  transition: opacity 0.5s;
  font-size: 1.14rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
}

.message.show {
  opacity: 1;
}

.message.success {
  color: #5cff9a;
}
.message.error {
  color: #ff6a6a;
}
.message.hint {
  color: #ffe66a;
}
.history {
  margin-top: 0.6rem;
  font-size: 1.06rem;
}

.history span {
  display: inline-block;
  background: #333;
  color: #fff;
  padding: 2.8px 12px;
  border-radius: 14px;
  margin: 2px;
  font-size: 0.98em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  letter-spacing: 0.5px;
}

.info-btn {
  position: absolute;
  left: 18px;
  top: 18px;
  font-size: 1.13rem;
  background: #444;
  color: #fff;
  border-radius: 50%;
  height: 2.1em;
  width: 2.1em;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.10);
  transition: background 0.2s;
}

.info-btn:focus {
  outline: 2px solid #00e6e6;
}

.howtoplay-popup {
  position: absolute;
  top: 45%;
  left: 50%;
  width: 98%;
  max-width: 350px;
  transform: translate(-50%, -50%);
  background: #141414;
  color: #fff;
  border-radius: 12px;
  padding: 1.2em 1.2em 1em 1.2em;
  box-shadow: 0 6px 36px rgba(0,0,0,0.25);
  font-size: 1.09em;
  z-index: 10;
  text-align: left;
  animation: fadeIn 0.3s;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -53%);}
  to { opacity: 1; transform: translate(-50%, -50%);}
}
.howtoplay-popup ul {
  margin: 0.5em 0 0.6em 1.4em;
  padding: 0;
}
.howtoplay-popup button {
  background: #333;
  font-size: 1em;
  padding: 0.27em 0.8em;
  border-radius: 5px;
  margin-top: 0.5em;
}

body.dark {
  background: #181818;
}

body.light {
  background: #ededed;
}
.game-container.dark {
  background: #222;
  color: #fff;
}
.game-container.light {
  background: #fff;
  color: #181818;
}
.game-container.light input[type="number"] {
  background: #f7f7f7;
  color: #181818;
}
.game-container.light .history span {
  background: #e5e5e5;
  color: #111;
}
.game-container.light .howtoplay-popup {
  background: #fff;
  color: #181818;
  border: 1px solid #ddd;
}

@media (max-width: 700px) {
  .game-container {
    width: 94vw;
    min-height: 65vw;
    padding: 2rem 0.7rem 2rem 0.7rem;
  }
  input[type="number"] {
    width: 100%;
    min-width: 0;
    max-width: 300px;
  }
  .howtoplay-popup {
    font-size: 0.97em;
  }
}

@media (max-width: 400px) {
  .game-container {
    width: 99vw;
    min-height: 340px;
    padding: 0.8rem 0.2rem 1rem 0.2rem;
  }
  .howtoplay-popup {
    max-width: 97vw;
    font-size: 0.89em;
    padding: 0.8em;
  }
  .input-row { flex-direction: column; gap: 0.4rem; }
}

/* --- Message color fixes for light mode --- */
.game-container.light .message.success {
  color: #228c22;
}
.game-container.light .message.hint {
  color: #b18904;
}
.game-container.light .message.error {
  color: #d32f2f;
}