/* ===== Meeple Wurf — Brettspiel-Theme ===== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --wood: #8a5a2b;
  --wood-dark: #5f3c1c;
  --wood-light: #b98044;
  --felt: #2e8b57;
  --felt-dark: #1f5f3c;
  --cream: #f7ecd7;
  --ink: #3b2a1a;
  --accent: #e0a526;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

body {
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.08), transparent 40%),
    linear-gradient(145deg, var(--wood) 0%, var(--wood-dark) 100%);
  min-height: 100vh;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 2rem;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  margin-bottom: 1.2rem;
}

.logo-badge {
  display: inline-block;
  background: var(--cream);
  border: 3px solid var(--wood-dark);
  border-radius: 50%;
  padding: 0.45rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
}

.logo-img {
  display: block;
  height: 64px;
  width: auto;
}

.logo-overlay {
  display: block;
  height: 72px;
  width: auto;
  margin: 0 auto 0.6rem;
}

.app-header h1 {
  font-size: 2rem;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--wood-dark);
  letter-spacing: 0.5px;
}

.subtitle {
  color: rgba(247, 236, 215, 0.85);
  font-size: 0.95rem;
}

/* ===== Rahmen / Tisch ===== */
.game-shell {
  width: 100%;
  max-width: 1000px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.hud-item {
  background: var(--wood-light);
  border: 2px solid var(--wood-dark);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  text-align: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), var(--shadow);
}

.hud-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--cream);
}

.hud-value {
  display: block;
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--ink);
}

/* ===== Canvas-Bereich ===== */
#canvas-wrap {
  position: relative;
  width: 100%;
  border: 4px solid var(--wood-dark);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--felt-dark);
  aspect-ratio: 960 / 540;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* wichtig für Touch-Wurf */
  cursor: crosshair;
}

/* ===== Overlays ===== */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  transition: opacity 0.25s ease;
  overflow-y: auto; /* Box darf auf kleinen Screens scrollen, nichts wird abgeschnitten */
  padding: 0.6rem;
}

.overlay[hidden],
.overlay.hidden {
  display: none !important;
}

.overlay-box {
  background: var(--cream);
  border: 4px solid var(--wood-dark);
  border-radius: 16px;
  padding: 2rem 2.4rem;
  max-width: 440px;
  margin: auto; /* zentriert, schneidet aber bei Overflow oben nichts ab */
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.overlay-box h2 {
  font-size: 1.7rem;
  color: var(--ink);
  margin-bottom: 0.7rem;
}

.overlay-box p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 0.8rem;
}

.overlay-box .hint {
  font-size: 0.85rem;
  color: var(--felt-dark);
  font-style: italic;
}

button {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: bold;
  padding: 0.7rem 2rem;
  margin: 0.5rem 0.25rem 0;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  background: var(--accent);
  color: var(--ink);
  box-shadow: 0 4px 0 #a87e14;
}

button:hover { transform: translateY(-2px); }
button:active { transform: translateY(1px); box-shadow: 0 1px 0 #a87e14; }

button.ghost {
  background: transparent;
  color: var(--wood-dark);
  border: 2px solid var(--wood-dark);
  box-shadow: none;
}
button.ghost:hover { background: rgba(0,0,0,0.05); }
button.ghost:active { transform: translateY(1px); }

.footer-info {
  margin-top: 1rem;
  text-align: center;
  color: rgba(247, 236, 215, 0.8);
  font-size: 0.85rem;
}

/* ===== Touch-Steuerung (nur auf Mobilgeräten sichtbar) ===== */
#touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.7rem;
  display: none;
  justify-content: space-between;
  padding: 0 0.9rem;
  pointer-events: none;
  z-index: 5;
}
.tc-group {
  display: flex;
  gap: 0.7rem;
}
#touch-controls button {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  background: rgba(247, 236, 215, 0.6);
  border: 2px solid var(--wood-dark);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  color: var(--ink);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#touch-controls button:active {
  transform: translateY(2px);
  box-shadow: none;
}
@media (pointer: coarse) {
  body.playing #touch-controls { display: flex; }
}

/* ===== Dreh-Hinweis (Handy hochkant während des Spiels) ===== */
#rotate-hint {
  position: absolute;
  left: 50%;
  top: 0.5rem;
  transform: translateX(-50%);
  background: rgba(30, 20, 10, 0.75);
  color: var(--cream);
  font-size: 0.75rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  display: none;
  pointer-events: none;
  z-index: 6;
  white-space: nowrap;
}
@media (orientation: portrait) and (pointer: coarse) {
  body.playing #rotate-hint { display: block; }
}

/* ===== Kompakter Header auf flachen Screens (Handy quer) ===== */
@media (max-height: 500px) {
  body { padding: 0.5rem 0.6rem 0.8rem; }
  .app-header { margin-bottom: 0.4rem; }
  .logo-badge { padding: 0.2rem; margin-bottom: 0.15rem; }
  .logo-img { height: 30px; }
  .app-header h1 { font-size: 1.2rem; }
  .subtitle { display: none; }
  .hud { gap: 0.4rem; margin-bottom: 0.4rem; }
  .hud-item { padding: 0.2rem 0.4rem; }
  .hud-label { font-size: 0.55rem; }
  .hud-value { font-size: 1rem; }
  .footer-info { display: none; }
  /* Canvas nach verfügbare Höhe statt Breite dimensionieren */
  #canvas-wrap {
    height: min(calc(100vh - 134px), 56.25vw);
    width: auto;
    aspect-ratio: 960 / 540;
    margin: 0 auto;
  }
}

/* ===== Vollbild-App-Modus: Handy quer => alles außer Spielfeld ausblenden ===== */
@media (max-height: 500px) and (pointer: coarse) {
  body { padding: 0; overflow: hidden; }
  .app-header, .hud, .footer-info { display: none; }
  #canvas-wrap {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: var(--wood-dark);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #game {
    width: min(100vw, calc(100vh * 1.77778));
    height: min(100vh, calc(100vw / 1.77778));
  }
  .overlay-box { padding: 0.8rem 1rem; }
  .overlay-box h2 { font-size: 1.2rem; margin-bottom: 0.4rem; }
  .overlay-box p { font-size: 0.8rem; margin-bottom: 0.5rem; }
  .overlay-box .hint { font-size: 0.72rem; }
  .logo-overlay { height: 44px; margin-bottom: 0.4rem; }
  button { font-size: 0.9rem; padding: 0.5rem 1.3rem; margin-top: 0.3rem; }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .hud { grid-template-columns: repeat(2, 1fr); }
  .overlay { position: fixed; inset: 0; z-index: 50; } /* ganzer Screen statt Mini-Canvas */
  .overlay-box { padding: 1rem 1.1rem; max-width: 92%; }
  .overlay-box h2 { font-size: 1.25rem; }
  .overlay-box p { font-size: 0.82rem; }
  .overlay-box .hint { font-size: 0.75rem; }
  .logo-overlay { height: 52px; }
  button { font-size: 0.95rem; padding: 0.55rem 1.4rem; }
}