* {
  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.5;
  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;
}

.word-stage {
  min-height: 130px;
  display: grid;
  place-items: center;
  text-align: center;
  transition: all 0.8s ease;
}

.word-stage.word-up {
  min-height: 78px;
  transform: translateY(-4px);
}

.word-box {
  font-size: clamp(36px, 10vw, 58px);
  font-weight: 900;
  letter-spacing: 1px;
  background: #2b2c31;
  border: 1px solid #3b3d45;
  border-radius: 18px;
  padding: 18px 28px;
  margin-top: 6px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.25);
  animation: wordReveal 0.55s ease;
  transition: all 0.8s ease;
}

.word-stage.word-up .word-box {
  font-size: 26px;
  padding: 10px 18px;
  border-radius: 14px;
  opacity: 0.82;
}

.chat-stage {
  animation: slideUp 0.25s ease;
}

.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: 62px;
  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;
}

.messages-box {
  min-height: 190px;
  max-height: 240px;
  overflow-y: auto;
  background: #0b0b0d;
  border: 1px solid #2d2f36;
  border-radius: 16px;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.chat-message {
  background: #2b2c31;
  border-radius: 12px;
  padding: 10px 12px;
}

.chat-name {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.65;
  margin-bottom: 3px;
}

.chat-word {
  font-size: 20px;
  font-weight: 900;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.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;
}

.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 wordReveal {
  from {
    opacity: 0;
    transform: scale(0.82) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@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 {
    min-height: 100dvh;
    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,
  .input-row {
    grid-template-columns: 1fr;
  }

  .room-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .room-code {
    font-size: 26px;
  }

  .countdown-number {
    font-size: 88px;
  }

  .messages-box {
    min-height: 170px;
  }
}
.my-turn-active {
  padding: 10px;
  border: 2px solid #8df04f;
  border-radius: 14px;
  background: rgba(83, 141, 78, 0.18);
  animation: myTurnGlow 0.8s infinite alternate;
}

.my-turn-body .turn-card {
  border-color: #8df04f;
  box-shadow: 0 0 22px rgba(141, 240, 79, 0.25);
}

.self-vote-disabled {
  opacity: 0.35;
}

.messages-box {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

@keyframes myTurnGlow {
  from {
    box-shadow: 0 0 0 rgba(141, 240, 79, 0);
  }
  to {
    box-shadow: 0 0 22px rgba(141, 240, 79, 0.35);
  }
}