:root {
  --leaf-dark: #143b27;
  --leaf: #1f6b36;
  --leaf-light: #6bbf45;
  --sky: #55b9e9;
  --wood: #5b3519;
  --wood-light: #9a642b;
  --gold: #ffd43b;
  --stone: #ded0a8;
  --paper: #fff4c8;
  --text: #fff9df;
  --shadow: rgba(18, 32, 22, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 16% 10%, rgba(255, 212, 59, 0.16), transparent 24%),
    radial-gradient(circle at 86% 84%, rgba(85, 185, 233, 0.22), transparent 28%),
    linear-gradient(145deg, #0b2419 0%, #15412b 48%, #143b48 100%);
}

button {
  font: inherit;
}

.game-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.game-card {
  width: min(1180px, 100%);
  border: 3px solid #2f2112;
  border-radius: 8px;
  overflow: hidden;
  background: #0f2118;
  box-shadow: 0 22px 60px var(--shadow), inset 0 0 0 1px rgba(255, 232, 151, 0.16);
}

.game-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  background:
    linear-gradient(90deg, rgba(63, 38, 18, 0.96), rgba(121, 73, 28, 0.94)),
    repeating-linear-gradient(90deg, transparent 0 28px, rgba(255, 255, 255, 0.05) 29px 30px);
  border-bottom: 3px solid #24160d;
}

.title-block {
  min-width: 0;
}

.designer,
.class-name {
  margin: 0;
  color: #ffe897;
  font-weight: 800;
  letter-spacing: 0;
  text-shadow: 0 2px 0 #2c1b0f;
}

.designer {
  font-size: clamp(0.95rem, 1.6vw, 1.25rem);
}

.class-name {
  font-size: clamp(0.9rem, 1.35vw, 1.05rem);
}

h1 {
  margin: 2px 0;
  color: #8ee33d;
  font-size: clamp(1.65rem, 4vw, 3.4rem);
  line-height: 0.98;
  text-shadow:
    0 3px 0 #215213,
    0 6px 0 #6e350e,
    0 9px 18px rgba(0, 0, 0, 0.28);
}

.hud {
  display: flex;
  gap: 10px;
  align-items: stretch;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.hud-item,
.icon-button {
  min-width: 86px;
  border: 2px solid #d99c34;
  border-radius: 8px;
  background: rgba(38, 24, 12, 0.88);
  color: var(--text);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.hud-item {
  padding: 8px 10px;
  text-align: center;
}

.hud-item span {
  display: block;
  color: #ffe897;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hud-item strong {
  display: block;
  color: var(--gold);
  font-size: 1.35rem;
  line-height: 1.1;
  text-shadow: 0 2px 0 #5d2c08;
}

.icon-button {
  min-height: 56px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 900;
}

.icon-button.is-muted {
  color: #c7b58b;
  border-color: #806431;
  background: rgba(31, 24, 17, 0.88);
}

.play-wrap {
  position: relative;
  overflow: hidden;
  background: #071711;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 188px);
  object-fit: contain;
  background: #0b2018;
}

.message-panel {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(520px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  padding: 24px;
  border: 3px solid #d99c34;
  border-radius: 8px;
  background:
    linear-gradient(rgba(46, 28, 13, 0.94), rgba(28, 18, 10, 0.96)),
    repeating-linear-gradient(90deg, transparent 0 22px, rgba(255, 255, 255, 0.04) 23px 24px);
  color: var(--text);
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.message-panel::before {
  content: "Designed by Mohammad Albarakati - Class: 5Q";
  display: block;
  margin-bottom: 10px;
  color: #ffe897;
  font-size: 0.95rem;
  font-weight: 900;
}

.message-panel.is-hidden {
  display: none;
}

.message-panel h2 {
  margin: 0 0 10px;
  color: #8ee33d;
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1.05;
  text-shadow: 0 3px 0 #215213, 0 6px 0 #6e350e;
}

.message-panel p {
  margin: 0 auto 18px;
  max-width: 42ch;
  color: #fff3c4;
  font-size: 1.02rem;
  line-height: 1.45;
}

.message-panel button {
  min-width: 190px;
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(#9af34a, #47b825);
  color: #17350e;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  box-shadow: 0 5px 0 #235612, 0 12px 24px rgba(0, 0, 0, 0.25);
}

.touch-controls {
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 6px;
  opacity: 0.92;
}

.play-wrap.is-menu .touch-controls {
  display: none;
}

.touch-controls button {
  border: 2px solid #e5c579;
  border-radius: 8px;
  background: rgba(52, 32, 15, 0.86);
  color: #ffe897;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  text-shadow: 0 2px 0 #27170b;
  touch-action: none;
}

.touch-controls button[data-dir="up"] {
  grid-column: 2;
  grid-row: 1;
}

.touch-controls button[data-dir="left"] {
  grid-column: 1;
  grid-row: 2;
}

.touch-controls button[data-dir="down"] {
  grid-column: 2;
  grid-row: 3;
}

.touch-controls button[data-dir="right"] {
  grid-column: 3;
  grid-row: 2;
}

.game-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  color: #ffe897;
  background: rgba(36, 22, 12, 0.92);
  border-top: 3px solid #24160d;
  font-size: 0.95rem;
  font-weight: 800;
}

@media (max-width: 760px) {
  .game-shell {
    align-items: start;
    padding: 8px;
  }

  .game-header {
    grid-template-columns: 1fr;
  }

  .hud {
    justify-content: stretch;
  }

  .hud-item {
    flex: 1 1 72px;
    min-width: 0;
  }

  .icon-button {
    flex: 1 1 100%;
  }

  canvas {
    max-height: none;
  }

  .touch-controls {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    left: 10px;
    bottom: 10px;
  }

  .message-panel {
    padding: 12px;
  }

  .message-panel h2 {
    font-size: 1.25rem;
  }

  .message-panel p {
    margin-bottom: 12px;
    font-size: 0.9rem;
    line-height: 1.35;
  }

  .message-panel button {
    min-height: 46px;
    min-width: 188px;
    font-size: 1.05rem;
  }

  .game-footer {
    display: none;
  }
}
