/* --- Reset & Base --- */
* {
  box-sizing: border-box;
}
html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  color: #68696a;
  font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}
html {
  font-size: 14px;
  -webkit-text-size-adjust: none;
}
a, button {
  touch-action: manipulation;
}

/* --- Header --- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  position: relative;
}
h1 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.4rem;
  font-weight: bold;
  margin: 0;
  letter-spacing: 0.18em;
  color: #d7dadc;
  font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
  text-shadow: 0 1px 0 #000;
  text-transform: uppercase;
  line-height: 1.1;
}
.left-button {
  background-color: white;
  color: black;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  text-decoration: none;
  white-space: nowrap;
}
.icons {
  display: flex;
  gap: 17px;
}
.icon-button {
  width: 25px;
  height: 25px;
}

/* --- Game Board --- */
.game-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  width: 100%;
  max-width: 500px; /* match keyboard */
}
.row {
  display: flex;
  justify-content: center;
  gap: 5px;
}
.tile {
  width: 62px;
  height: 62px;
  border: 2px solid #3a3a3c;
  background-color: #121213;
  color: #d7dadc;
  font-size: 2.2rem;
  font-weight: bold;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border 0.2s;
}

/* --- Keyboard --- */
.keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 32px auto 0 auto;
  width: 100%;
  max-width: 500px;
  padding: 0 8px;
}
.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  width: 100%;
}
.key {
  flex: 1 1 0;
  min-width: 32px;
  max-width: 43px;
  background-color: #818384;
  color: #fff;
  border: none;
  padding: 0;
  height: 58px;
  margin: 0;
  font-size: 1.2rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  user-select: none;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.key.special {
  flex: 1.5 1 0;
  max-width: 70px;
  background-color: #d3d6da;
  color: #000;
  font-weight: bold;
  height: 58px;
  font-size: 1.2rem;
  padding: 0;
}

/* --- Info Bar --- */
.info-bar {
  margin-top: 20px;
  text-align: center;
  color: #b3b3b3;
  font-size: 0.9rem;
}
.info-bar ul {
  padding-left: 1.2em;
  list-style: disc;
  color: #ccc;
}

/* --- End Screen --- */
.end-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(18, 18, 19, 0.95);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  z-index: 1000;
  flex-direction: column;
  text-align: center;
  padding: 20px;
}
.end-screen .code {
  margin-top: 10px;
  font-size: 1.5rem;
  color: #00ff95;
  font-family: monospace;
  background: #1d1d1f;
  padding: 8px 14px;
  border-radius: 6px;
  user-select: all;
}

/* --- Buttons --- */
.retry-button,
.popup-close,
.redeem-button {
  margin-top: 10px;
  background-color: #ffffff;
  color: #000000;
  border: none;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
.retry-button:hover,
.popup-close:hover,
.redeem-button:hover {
  background-color: #cccccc;
}
.retry-button:focus,
.popup-close:focus {
  outline: none;
  box-shadow: 0 0 0 2px #00ff95;
}
.retry-button:active,
.popup-close:active {
  background-color: #b3b3b3;
}
.retry-button:disabled {
  background-color: #666666;
  cursor: not-allowed;
  opacity: 0.5;
}

/* --- Popups --- */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 18, 19, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}
.popup-box {
  background: #1f1f1f;
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  max-width: 90%;
  color: #fff;
}
.popup-header {
  font-size: 1.5rem;
  margin-bottom: 10px;
  font-weight: bold;
}
.popup-content {
  font-size: 1rem;
  line-height: 1.5;
}

/* --- Responsive for mobile screens --- */
@media (max-width: 600px) {
  h1 {
    font-size: 2rem;
    letter-spacing: 0.12em;
  }
  .game-board {
    max-width: 98vw;
  }
  .tile {
    width: 18vw;
    height: 18vw;
    font-size: 1.3rem;
  }
  .keyboard {
    max-width: vw;
    padding: 0 2vw;
    gap: 8px;
  }
  .keyboard-row {
    gap: 4px;
  }
  .key, .key.special {
    min-width: 8vw;
    max-width: 15vw;
    height: 12vw;
    font-size: 1rem;
  }
}

/* --- Falling Animation --- */
.fall {
  animation: fall 7s forwards;
}
@keyframes fall {
  to { transform: translateY(100vh) rotate(30deg); opacity: 0; }
}

body {
  background: #121213 url('money.gif') center center no-repeat;
  background-size: cover;
  background-attachment: fixed;
}
