* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background-color: #1a1a2e;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)),
    url("../assets/image.png");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: #eee;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  padding: 1rem;
}

/* Мобильный: игра на весь экран, две рабочие строки сверху */
@media (max-width: 768px) {
  html, body {
    height: 100%;
    min-height: 100dvh;
    overflow: hidden;
  }
  body {
    align-items: stretch;
  }
  #app {
    min-height: 100%;
    padding: 0;
    max-width: none;
    display: flex;
    flex-direction: column;
  }
  .game-screen {
    display: flex !important;
    flex-direction: column;
    min-height: 100%;
    padding: 0;
    gap: 0;
  }
  .game-screen.hidden {
    display: none !important;
  }
  .game-toolbar-row {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    min-height: 2.5rem;
    background: #0f0f1a;
  }
  .game-toolbar-row-1 {
    padding-top: max(0.35rem, env(safe-area-inset-top));
  }
  .game-toolbar-row-2 {
    flex-wrap: wrap;
  }
  .game-toolbar-row .placement-msg {
    margin: 0;
    flex: 1;
    min-width: 0;
  }
  .game-container {
    flex: 1;
    min-height: 0;
    max-height: none;
    aspect-ratio: unset;
    border-radius: 0;
  }
}

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: 1rem;
  padding: 1rem;
}

.screen.hidden,
.hidden {
  display: none !important;
}

.title {
  font-size: 2.5rem;
  margin: 0 0 2rem;
  text-align: center;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.title-logo {
  max-height: 80px;
  width: auto;
  display: block;
}

.title-text {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
}

.subtitle {
  font-size: 1.25rem;
  margin: 0 0 1rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  min-width: 200px;
}

.btn-primary {
  background: #3498db;
  color: #fff;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-secondary {
  background: #555;
  color: #fff;
}

.btn-secondary:hover {
  background: #666;
}

.btn-small {
  min-width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.game-screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.game-toolbar,
.game-toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.game-screen .game-toolbar-row {
  margin-bottom: 0.25rem;
  flex-shrink: 0;
}

.status {
  flex: 1;
  font-size: 0.95rem;
}

.opponent-count {
  font-size: 0.85rem;
  opacity: 0.9;
  white-space: nowrap;
}

.placement-msg {
  color: #e74c3c;
  font-size: 0.9rem;
  margin: 0 0 0.25rem;
}

.game-container {
  width: 100%;
  flex: 1;
  min-height: 0;
  background: #0f0f1a;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
}

#game-canvas,
#game-canvas-result {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.game-screen {
  position: relative;
}

.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(0,0,0,0.8);
  padding: 2rem;
  border-radius: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.result-overlay.hidden {
  display: none !important;
}

.result-title {
  margin: 0;
  font-size: 2rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  max-width: 280px;
}

input[type="text"] {
  padding: 0.5rem;
  font-size: 1rem;
  border-radius: 6px;
  border: 1px solid #555;
  background: #333;
  color: #fff;
}

.hint {
  font-size: 0.85rem;
  color: #999;
  margin: 0;
}

@media (max-width: 480px) {
  .title { font-size: 1.75rem; }
  .title-logo { max-height: 56px; }
}
