:root {
  --bg: #050505;
  --text: #f4f4f4;
  --muted: #8a8a8a;
}

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

html, body {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  color-scheme: dark;
}

.tet-app {
  height: 100%;
  max-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 10px 16px 12px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  gap: 8px;
}

.tet-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  min-height: 52px;
  flex-wrap: nowrap;
}

.back-link,
.tet-top h1 {
  font-size: 26px;
  font-weight: 600;
}

.back-link {
  color: #fff;
  text-decoration: none;
  padding: 10px 18px;
  border: 2px solid #fff;
  border-radius: 999px;
  white-space: nowrap;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

.back-link:active {
  background: #fff;
  color: #000;
}

.scores {
  display: flex;
  gap: 16px;
  font-size: 20px;
  color: var(--muted);
  white-space: nowrap;
}

.scores b,
.side-label b {
  color: #fff;
  font-weight: 600;
}

.tet-main {
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: 18px;
  touch-action: none;
}

.board-wrap {
  height: 100%;
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  touch-action: none;
}

.board-frame {
  position: relative;
  height: 100%;
  width: auto;
  aspect-ratio: 1 / 2;
  max-width: 46vw;
  background: #0b0b0b;
  border: 1px solid #2a2a2a;
  border-radius: 20px;
  overflow: hidden;
}

#board,
#next {
  display: block;
}

#board {
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}

.overlay.hidden {
  display: none;
}

#overlay-text {
  font-size: 34px;
  font-weight: 600;
  text-align: center;
}

.hint,
.side-label {
  color: var(--muted);
  font-size: 20px;
  line-height: 1.35;
}

.hint {
  text-align: center;
}

.side {
  flex: 0 0 auto;
  width: 168px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 4px 10px 0;
  touch-action: none;
}

#next {
  width: 140px;
  height: 140px;
  background: #0b0b0b;
  border-radius: 16px;
}

@media (max-height: 700px) {
  .tet-app { padding: 8px 12px 10px; gap: 6px; }
  .tet-top { min-height: 46px; gap: 12px; }
  .back-link, .tet-top h1 { font-size: 22px; }
  .back-link { min-height: 44px; padding: 8px 14px; }
  .scores { font-size: 18px; gap: 12px; }
  #overlay-text { font-size: 28px; }
  .hint, .side-label { font-size: 18px; }
  #next { width: 110px; height: 110px; }
}

@media (max-width: 820px) {
  .board-frame { max-width: 42vw; }
  .tet-top h1 { display: none; }
}
