* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: #0b0d11;
  color: #e7e9ee;
  min-height: 100vh;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.screen {
  width: min(520px, 92vw);
  background: #11141a;
  border: 1px solid #1c212b;
  border-radius: 20px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.app-logo {
  width: 88px;
  height: 88px;
  border-radius: 18px;
  display: block;
  margin: 0 auto 14px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.hidden {
  display: none;
}

h1,
h2 {
  margin: 0 0 12px;
  font-weight: 600;
}

.subtitle {
  margin: 0 0 20px;
  color: #9aa4b2;
}

.info-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: -6px 0 14px;
  color: #9aa4b2;
}

button {
  border: none;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
  margin: 6px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

button:active {
  transform: scale(0.98);
}

.primary {
  background: #2463ff;
  color: #fff;
  box-shadow: 0 10px 18px rgba(36, 99, 255, 0.3);
}

.secondary {
  background: #1a1f28;
  color: #c8d0dc;
  border: 1px solid #2a3240;
}

#game-ui {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  background: radial-gradient(circle at top, #121723, #0b0d11 60%);
  border: none;
  overflow: hidden;
}

#start-screen,
#purchase-screen,
#final-screen,
#countdown-screen,
#leaderboard-screen,
#history-screen {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}

#start-screen.claim-active #buy-button-start {
  pointer-events: none;
  opacity: 0.6;
}

#leaderboard-screen {
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, 94vw);
}

#history-screen {
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, 94vw);
}

#start-screen,
#countdown-screen {
  left: 50%;
  transform: translate(-50%, -50%);
}

.leaderboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0 20px;
}

.history-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0 20px;
  text-align: left;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-bottom: 8px;
}

.history-header h2 {
  margin: 0;
}

.history-back {
  margin: 12px 0 0;
}

.history-dates h3,
.history-details h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #9aa4b2;
  font-weight: 600;
}

.history-dates-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.history-date-button {
  width: 100%;
  margin: 0;
  text-align: left;
}

.history-line {
  margin: 8px 0;
  color: #cbd5e1;
}

.leaderboard-column h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #9aa4b2;
  font-weight: 600;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  color: #e7e9ee;
  font-size: 12px;
  table-layout: fixed;
}

.leaderboard-table th {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.6px;
  color: #9aa4b2;
  padding: 4px 0;
  border-bottom: 1px solid #1c212b;
}

.leaderboard-table td {
  padding: 6px 0;
  border-bottom: 1px solid #1c212b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-table th:nth-child(1),
.leaderboard-table td:nth-child(1) {
  width: 18%;
}

.leaderboard-table th:nth-child(2),
.leaderboard-table td:nth-child(2) {
  width: 42%;
}

.leaderboard-table th:nth-child(3),
.leaderboard-table td:nth-child(3) {
  width: 40%;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 10px;
  color: #cbd5e1;
  border-bottom: 1px solid #1c212b;
}

.leaderboard-button {
  margin: 0;
}

.claim-bar {
  width: 100%;
  padding: 10px 20px 0;
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 20;
  margin: 6px 0 4px;
}

.claim-bar.hidden {
  display: none;
}

.claim-button {
  margin: 0;
  width: min(420px, 92%);
  font-weight: 600;
  background: #22c55e;
  color: #0b0f0d;
  border: 1px solid #1da951;
  box-shadow: 0 10px 18px rgba(34, 197, 94, 0.25);
}

#timer-block {
  display: none;
}

#game-ui.is-game #timer-block {
  display: flex;
}

#game-ui.is-game #prize-pool-block {
  display: none;
}

#game-ui.is-game #games-left-top {
  display: flex;
}

#games-left-top {
  display: none;
}

.bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 16px;
  z-index: 12;
}

.bottom-bar.hidden {
  display: none;
}

.rules-button {
  margin: 0;
  flex: 0 0 auto;
}

.history-button {
  margin: 0;
  flex: 0 1 auto;
  width: fit-content;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-button:active {
  transform: scale(0.98);
}

.games-left-corner {
  margin: 0;
  color: #cbd5e1;
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
  flex: 0 0 auto;
}

.bottom-underline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 72px;
  height: 1px;
  background: #1c212b;
  opacity: 0.9;
  z-index: 11;
}

.modal {
  position: absolute;
  inset: 0;
  background: rgba(11, 13, 17, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(520px, 92vw);
  background: #11141a;
  border: 1px solid #1c212b;
  border-radius: 18px;
  padding: 20px 22px;
  text-align: left;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-body p {
  margin: 0 0 10px;
  color: #cbd5e1;
}

.modal-body ul {
  margin: 0 0 10px 18px;
  color: #cbd5e1;
}

#history-list {
  margin: 0 0 10px 18px;
  padding: 0;
  list-style: disc;
  color: #cbd5e1;
}

#history-list li {
  margin: 0 0 6px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.stat strong {
  font-size: 18px;
  color: #f8fafc;
}

#game-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.coin {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(18, 24, 33, 0.9);
  border: 1px solid #2a3240;
  border-radius: 16px;
  cursor: pointer;
  animation: pop-in 0.18s ease;
  backdrop-filter: blur(8px);
  min-width: 86px;
  user-select: none;
  touch-action: manipulation;
}

.coin img {
  width: 38px;
  height: 38px;
}

.coin span {
  font-size: 12px;
  color: #d1d7e3;
  letter-spacing: 0.4px;
}

.coin-progress {
  width: 100%;
  height: 4px;
  background: #1c2230;
  border-radius: 999px;
  overflow: hidden;
}

.coin-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4f9bff, #2463ff);
  width: 100%;
  transition: width 0.08s linear;
}

.coin:active {
  transform: scale(0.95);
}

#floating-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.float-text {
  position: absolute;
  color: #9fe870;
  font-weight: 600;
  animation: float-up 0.7s ease forwards;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.result-line {
  margin: 8px 0;
  color: #cbd5e1;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes float-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(-16px);
  }
}

@media (max-width: 640px) {
  #game-ui {
    height: min(620px, 86vh);
  }

  .top-bar {
    padding: 14px 12px 8px;
  }

  .bottom-bar {
    padding: 0 12px;
    gap: 6px;
    bottom: 16px;
  }

  .history-layout {
    grid-template-columns: 1fr;
  }

  .rules-button,
  .history-button {
    font-size: 12px;
    padding: 10px 10px;
  }

  .games-left-corner {
    font-size: 12px;
  }

  .coin {
    min-width: 76px;
    padding: 8px 10px;
  }
}
