* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  touch-action: manipulation;
}

body {
  min-height: 100dvh;
  background: #0f1012;
  color: #fff;
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 32px 20px 20px;
  overflow-x: hidden;
}

.app {
  width: 100%;
  max-width: 560px;
  background: #1c1d22;
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: 100px 1fr 100px;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.topbar h1 {
  margin: 0;
  text-align: center;
  font-size: 28px;
  line-height: 1.1;
}

.topbar-spacer {
  width: 100%;
  min-height: 40px;
}

.nav-btn {
  appearance: none;
  border: none;
  text-decoration: none;
  background: #3a3b40;
  color: #fff;
  border-radius: 10px;
  min-height: 42px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}

.nav-btn:hover {
  transform: translateY(-1px);
}

.nav-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.green-btn,
.ready-btn,
.share-btn {
  background: #538d4e;
}

.gray-btn {
  background: #44474f;
}

.ready-btn {
  width: 100%;
  font-size: 18px;
  min-height: 52px;
  margin-top: 12px;
}

.ready-btn.ready-active {
  background: #3f6db3;
}

.wide-btn {
  width: 100%;
  margin-top: 14px;
}

.screen {
  animation: fadeIn 0.18s ease;
}

.panel {
  background: #17181b;
  border: 1px solid #2d2f36;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}

.panel-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.center {
  text-align: center;
}

.small-label {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.72;
  margin-bottom: 4px;
}

.text-input {
  width: 100%;
  border: none;
  outline: none;
  background: #2b2c31;
  color: #fff;
  border-radius: 10px;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 700;
}

.text-input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.main-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.join-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.room-card {
  background: #2a2b30;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.room-code {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 4px;
}

.players-list {
  display: grid;
  gap: 8px;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #2b2c31;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
}

.player-ready {
  color: #8df04f;
}

.player-waiting {
  opacity: 0.65;
}

.countdown-box {
  min-height: 340px;
  display: grid;
  place-items: center;
  text-align: center;
}

.countdown-number {
  font-size: 110px;
  font-weight: 900;
  line-height: 1;
  animation: pop 0.7s ease;
}

.countdown-text {
  font-size: 18px;
  font-weight: 700;
  opacity: 0.8;
  margin-top: 10px;
}

.boxes-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.box-btn {
  aspect-ratio: 1;
  border: 2px solid #d8d8d8;
  background: #17181b;
  color: #fff;
  border-radius: 16px;
  font-size: 34px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}

.box-btn:hover {
  transform: translateY(-2px);
}

.box-btn:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

.box-btn.chosen {
  background: #3f6db3;
  border-color: #fff;
}

.reveal-card {
  min-height: 330px;
  background: #17181b;
  border: 1px solid #2d2f36;
  border-radius: 18px;
  padding: 18px;
  display: grid;
  place-items: center;
  text-align: center;
  animation: resultPop 0.35s ease;
}

.reveal-icon {
  width: 150px;
  height: 150px;
  border: 4px solid #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 78px;
  font-weight: 900;
  box-shadow: 0 0 24px rgba(255,255,255,0.18);
}

.reveal-icon.empty {
  border-radius: 18px;
}

.reveal-text {
  font-size: 28px;
  font-weight: 900;
}

.turn-card {
  background: #17181b;
  border: 1px solid #2d2f36;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.turn-name {
  font-size: 22px;
  font-weight: 900;
}

.timer-pill {
  min-width: 72px;
  background: #3f6db3;
  border-radius: 999px;
  padding: 8px 12px;
  text-align: center;
  font-weight: 900;
}

.timer-pill.danger {
  background: #b34747;
  animation: pulse 0.55s infinite alternate;
}

.voting-stage {
  animation: fadeIn 0.22s ease;
}

.vote-buttons {
  display: grid;
  gap: 10px;
}

.vote-btn {
  width: 100%;
  min-height: 52px;
  background: #2b2c31;
  border: 1px solid #3b3d45;
  justify-content: space-between;
}

.vote-btn.voted {
  background: #3f6db3;
}

.result-stage {
  background: #17181b;
  border: 1px solid #2d2f36;
  border-radius: 18px;
  padding: 16px;
  text-align: center;
  animation: resultPop 0.35s ease;
}

.result-title {
  font-size: 30px;
  font-weight: 900;
  margin-bottom: 10px;
}

.result-text {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 14px;
}

.vote-reveal {
  display: grid;
  gap: 8px;
  text-align: left;
}

.vote-line {
  background: #2b2c31;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.message {
  min-height: 24px;
  text-align: center;
  margin-top: 12px;
  font-size: 15px;
  font-weight: 700;
  opacity: 0.9;
}

.copy-toast {
  position: fixed;
  top: 18px;
  right: 18px;
  background: #2f2f31;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  border: 1px solid #4a4a4d;
  z-index: 999;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.55);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes resultPop {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

@media (max-width: 600px) {
  body {
    padding: 22px 12px 12px;
  }

  .app {
    padding: 14px;
    border-radius: 20px;
  }

  .topbar {
    grid-template-columns: 78px 1fr 78px;
    gap: 8px;
  }

  .topbar h1 {
    font-size: 21px;
  }

  .nav-btn {
    min-height: 38px;
    font-size: 12px;
    padding: 8px 10px;
  }

  .main-actions,
  .join-box {
    grid-template-columns: 1fr;
  }

  .room-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .room-code {
    font-size: 26px;
  }

  .countdown-number {
    font-size: 88px;
  }

  .boxes-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .turn-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .timer-pill {
    width: 100%;
  }
}