:root {
  --felt: #1f7a4f;
  --felt-dark: #0f5736;
  --wood: #6e4a2e;
  --wood-dark: #4a321f;
  --light: #e7ecef;
  --dark: #0c0f12;
}
* {
  box-sizing: border-box;
}
html, body {
  height: 100%;
  margin: 0;
  background: var(--dark);
  color: var(--light);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.wrap {
  max-width: 1000px;
  margin: 24px auto;
  padding: 0 16px;
  display: grid;
  gap: 16px;
}
header {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}
header h1 {
  font-size: clamp(20px, 3vw, 26px);
  margin: 0;
  color: var(--light);
  font-weight: 700;
}
header .btns {
  display: flex;
  gap: 10px;
}
button {
  background: linear-gradient(180deg, var(--wood), var(--wood-dark));
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
}
button:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

#restartBtn.restart-waiting {
  background: linear-gradient(180deg, #7b8794, #54606c);
}

#restartBtn.restart-attention {
  background: linear-gradient(180deg, #17a2b8, #0f7d8f);
  box-shadow: 0 0 0 1px rgba(23,162,184,.25), 0 6px 18px rgba(7,96,109,.45);
  animation: restartPulse 1.2s ease-in-out infinite;
}

@keyframes restartPulse {
  0%, 100% { filter: brightness(1); transform: translateY(0); }
  50% { filter: brightness(1.12); transform: translateY(-1px); }
}
.hint {
  opacity: .7;
  font-size: 14px;
  text-align: center;
}
.table-wrap {
  width: 100%;
  aspect-ratio: 2 / 1;
  background: var(--wood-dark);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  position: relative;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 14px;
  background: radial-gradient(120% 120% at 80% 20%, var(--felt) 0%, var(--felt-dark) 70%);
  cursor: crosshair;
  touch-action: none;
}
.score {
  position: absolute;
  inset: auto 12px 12px auto;
  background: rgba(0,0,0,.45);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

@media (max-width: 900px) {
  .wrap {
    margin: 14px auto;
    gap: 12px;
  }

  header {
    flex-direction: column;
    align-items: stretch;
  }

  header .btns {
    width: 100%;
  }

  button {
    min-height: 44px;
    flex: 1;
  }
}

@media (max-width: 640px) {
  html, body {
    overflow-x: hidden;
  }

  .wrap {
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
    margin: 0 auto;
    gap: 10px;
  }

  header h1 {
    text-align: center;
  }

  header .btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .table-wrap {
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 12px 36px rgba(0,0,0,.45);
  }

  canvas {
    border-radius: 10px;
  }

  .hint {
    font-size: 12px;
    line-height: 1.35;
  }

  .score {
    inset: auto 8px 8px auto;
    font-size: 12px;
    padding: 6px 8px;
  }
}
