/* 교통지옥 TRAFFIC HELL */
:root {
  --bg: #0d1117;
  --bg2: #151b24;
  --card: #1a222d;
  --line: #2a3442;
  --ink: #e9eef4;
  --mute: #8d99a8;
  --hot: #ff4d3a;
  --amber: #ffc233;
  --go: #33dd7a;
  --blue: #4aa3ff;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans KR", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}
[hidden] {
  display: none !important;
}
.th-screen:not(.th-game) {
  max-width: 1100px;
  margin: 0 auto;
}
.th-screen {
  padding: 12px 16px 28px;
}
.th-top,
.th-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding-left: 70px; /* 공용 집 버튼 자리 */
}
.th-back,
.th-back-btn {
  color: var(--mute);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  background: none;
  border: 0;
  padding: 8px 4px;
}
.th-date {
  margin-left: auto;
  color: var(--mute);
  font: 700 13px Outfit, sans-serif;
}
.th-pill {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  min-height: 36px;
}
.th-muted {
  color: var(--mute);
}
.th-small {
  font-size: 12px;
}

/* 로고 */
.th-logo {
  text-align: center;
  padding: 18px 0 14px;
}
.th-logo-light {
  display: inline-flex;
  gap: 6px;
  background: #0a0d12;
  border: 2px solid #2a3240;
  border-radius: 14px;
  padding: 7px 10px;
  margin-bottom: 8px;
}
.th-logo-light i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2a2f37;
}
.th-logo-light i:nth-child(1) {
  background: var(--hot);
  box-shadow: 0 0 14px var(--hot);
  animation: thlight 3.6s infinite;
}
.th-logo-light i:nth-child(2) {
  animation: thlight2 3.6s infinite;
}
.th-logo-light i:nth-child(3) {
  animation: thlight3 3.6s infinite;
}
@keyframes thlight {
  0%, 30% { background: var(--hot); box-shadow: 0 0 14px var(--hot); }
  34%, 100% { background: #2a2f37; box-shadow: none; }
}
@keyframes thlight2 {
  0%, 85% { background: #2a2f37; box-shadow: none; }
  88%, 100% { background: var(--amber); box-shadow: 0 0 14px var(--amber); }
}
@keyframes thlight3 {
  0%, 33% { background: #2a2f37; box-shadow: none; }
  36%, 84% { background: var(--go); box-shadow: 0 0 14px var(--go); }
  86%, 100% { background: #2a2f37; box-shadow: none; }
}
.th-logo h1 {
  margin: 0;
  line-height: 1;
}
.th-logo h1 span {
  display: block;
  font-size: clamp(40px, 11vw, 64px);
  font-weight: 900;
  letter-spacing: -2px;
  background: linear-gradient(180deg, #fff 0%, #ffd9cf 55%, #ff6a4d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.th-logo h1 small {
  display: block;
  font: 900 15px Outfit, sans-serif;
  letter-spacing: 7px;
  color: var(--amber);
  margin-top: 6px;
}
.th-slogan {
  margin: 10px 0 0;
  color: var(--mute);
  font-weight: 500;
}

/* 모드 */
.th-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 14px;
}
.th-mode {
  text-align: left;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #1d2633, #141a23);
  border-radius: 16px;
  padding: 14px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.12s, border-color 0.12s;
}
.th-mode:hover,
.th-mode:focus-visible {
  border-color: var(--amber);
  transform: translateY(-1px);
}
.th-mode b {
  font-size: 17px;
  font-weight: 900;
}
.th-mode span {
  font-size: 12.5px;
  color: var(--mute);
  line-height: 1.45;
}
.th-mode em {
  margin-top: auto;
  font-style: normal;
  font: 800 12.5px Outfit, "Noto Sans KR", sans-serif;
  color: var(--amber);
}
.th-mode-daily {
  grid-column: 1 / -1;
  background: linear-gradient(120deg, #3a1714, #1c1416 55%, #161c26);
  border-color: #5a2a24;
}
.th-mode-daily b {
  font-size: 20px;
}

/* 패널 */
.th-panel {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
}
.th-panel-h {
  margin: 0 0 10px;
  font-size: 16px;
}
.th-sub {
  font-size: 13px;
  color: var(--mute);
  margin: 14px 0 6px;
}
.th-missions,
.th-recent,
.th-board-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.th-missions li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.th-missions li:first-child {
  border-top: 0;
}
.th-missions li p {
  margin: 0;
  flex: 1;
  font-size: 14px;
}
.th-missions li span {
  color: var(--mute);
}
.th-missions li.ok span,
.th-missions li.ok em {
  color: var(--go);
}
.th-missions em {
  font-style: normal;
  font: 800 13px Outfit, sans-serif;
  color: var(--mute);
}
.th-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.th-stats div {
  background: var(--card);
  border-radius: 10px;
  padding: 8px 10px;
}
.th-stats span {
  display: block;
  font-size: 11.5px;
  color: var(--mute);
}
.th-stats b {
  font-size: 15px;
}
.th-board-list li,
.th-recent li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.th-board-list li:first-child,
.th-recent li:first-child {
  border-top: 0;
}
.th-board-list b {
  width: 22px;
  color: var(--amber);
  font-family: Outfit, sans-serif;
}
.th-board-list span,
.th-recent span {
  flex: 1;
}
.th-board-list em {
  font-style: normal;
  font: 800 14px Outfit, sans-serif;
}
.th-recent em {
  font-style: normal;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #3a1d1d;
  color: #ff9a8a;
}
.th-recent em.w {
  background: #173825;
  color: #7ee8a6;
}
.th-recent b {
  font-family: Outfit, sans-serif;
}
.th-recent small {
  color: var(--mute);
}

/* 고르기 */
.th-pick-h {
  margin: 0;
  font-size: 17px;
  flex: 1;
}
.th-chap {
  font-size: 13px;
  color: var(--amber);
  margin: 16px 0 8px;
}
.th-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.th-card {
  position: relative;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.th-card:not(.lock):hover,
.th-card:focus-visible {
  border-color: var(--amber);
}
.th-card.done {
  border-color: #2c5a3e;
}
.th-card.lock {
  opacity: 0.45;
  cursor: not-allowed;
}
.th-card-n {
  font: 900 22px Outfit, sans-serif;
  color: var(--amber);
}
.th-card b {
  font-size: 14.5px;
}
.th-card small {
  font-size: 11.5px;
  color: var(--mute);
}
.th-card em {
  margin-top: auto;
  font-style: normal;
  font: 800 12px Outfit, "Noto Sans KR", sans-serif;
}
.th-stars i {
  font-style: normal;
  color: #3a4250;
  font-size: 15px;
}
.th-stars i.on {
  color: var(--amber);
}

/* 게임 화면 */
.th-game {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  gap: 6px;
}
.th-hud-mode {
  flex: 1;
  min-width: 0;
  line-height: 1.15;
}
.th-hud-mode b {
  display: block;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.th-hud-mode small {
  display: block;
  font-size: 11px;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.th-bar {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}
.th-bar > div {
  position: relative;
  background: var(--card);
  border-radius: 9px;
  padding: 4px 6px;
  overflow: hidden;
  min-width: 0;
}
.th-bar span {
  display: block;
  font-size: 10px;
  color: var(--mute);
  white-space: nowrap;
}
.th-bar b {
  font: 800 15px Outfit, "Noto Sans KR", sans-serif;
  white-space: nowrap;
}
.th-bar small {
  font-size: 10px;
  color: var(--mute);
  margin-left: 1px;
}
.th-cong i {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: var(--go);
  transition: width 0.3s;
}
.th-cong.warn i {
  background: var(--amber);
}
.th-cong.bad i {
  background: var(--hot);
}
.th-cong.bad b {
  color: var(--hot);
}
.th-bar .bad b {
  color: var(--hot);
}
.th-bar .em {
  background: #3b1414;
  animation: thpulse 0.8s infinite alternate;
}
@keyframes thpulse {
  to {
    background: #18264a;
  }
}
.th-score b {
  color: var(--amber);
}
.th-stage {
  position: relative;
  flex: 1;
  min-height: 220px;
  border-radius: 14px;
  overflow: hidden;
  background: #222831;
}
#cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.th-coach {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  background: rgba(10, 14, 20, 0.88);
  border: 1px solid var(--amber);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  pointer-events: none;
}
.th-coach b {
  color: var(--amber);
}
.th-banner {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  background: rgba(150, 20, 20, 0.92);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 900;
  font-size: 15px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  max-width: 88%;
}
.th-banner.on {
  animation: thbanner 2.6s ease forwards;
}
@keyframes thbanner {
  0% { opacity: 0; transform: translate(-50%, -40%); }
  12%, 75% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}
.th-paused {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 14, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.th-dock {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 8px 8px;
}
.th-dock-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--mute);
  margin-bottom: 5px;
  min-height: 26px;
}
.th-dock-t {
  margin-left: auto;
  font: 700 12px Outfit, "Noto Sans KR", sans-serif;
}
.th-dock-t.warn {
  color: var(--amber);
}
.th-isel {
  display: flex;
  gap: 4px;
}
.th-isel button {
  min-width: 36px;
  min-height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  font: 900 14px Outfit, sans-serif;
}
.th-isel button.on {
  background: var(--amber);
  color: #1a1200;
  border-color: var(--amber);
}
.th-phases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 6px;
}
.th-ph {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 5px 6px;
  min-height: 48px;
  text-align: left;
}
.th-ph .ic svg {
  width: 34px;
  height: 34px;
  display: block;
}
.th-ph .nm {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}
.th-ph kbd {
  position: absolute;
  right: 5px;
  top: 3px;
  font: 700 9px Outfit, sans-serif;
  color: var(--mute);
}
.th-ph.cur {
  border-color: var(--go);
  background: #12301f;
  box-shadow: inset 0 0 0 1px var(--go);
}
.th-ph.next {
  border-color: var(--amber);
  background: #33280d;
}

/* 모달 · 토스트 */
.th-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.th-modal-box {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  overflow: auto;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 18px 18px;
}
.th-modal-box h2 {
  margin: 2px 0 8px;
  font-size: 24px;
}
.th-modal-box h2.w {
  color: var(--go);
}
.th-modal-box h2.l {
  color: var(--hot);
}
.th-modal-box p {
  line-height: 1.6;
  font-size: 14.5px;
}
.th-modal-x {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 40px;
  height: 40px;
  border: 0;
  background: none;
  font-size: 18px;
  color: var(--mute);
}
.th-kicker {
  margin: 0;
  font: 800 12px Outfit, "Noto Sans KR", sans-serif;
  color: var(--amber);
  letter-spacing: 1px;
}
.th-goal {
  background: var(--card);
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
}
.th-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.th-chips span {
  background: #232c38;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12.5px;
}
.th-tips {
  margin: 0 0 6px;
  padding-left: 18px;
  font-size: 13.5px;
  color: #c5cfdb;
  line-height: 1.6;
}
.th-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.th-btn {
  flex: 1;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  font-weight: 800;
  font-size: 15px;
}
.th-btn-hot {
  background: linear-gradient(180deg, #ff6a4d, #e2361f);
  border-color: #ff6a4d;
  color: #fff;
}
.th-reason {
  color: var(--mute);
  margin: 0;
}
.th-bigstars .th-stars i {
  font-size: 34px;
}
.th-final {
  font: 900 40px Outfit, sans-serif;
  margin: 6px 0;
}
.th-final small {
  font-size: 18px;
  margin-left: 2px;
}
.th-new {
  font-style: normal;
  font-size: 13px;
  background: var(--amber);
  color: #1a1200;
  padding: 3px 8px;
  border-radius: 6px;
  vertical-align: middle;
}
.th-res-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.th-res-grid div {
  background: var(--card);
  border-radius: 10px;
  padding: 7px 8px;
}
.th-res-grid span {
  display: block;
  font-size: 11px;
  color: var(--mute);
}
.th-res-grid b {
  font-size: 14px;
}
.th-break {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 13.5px;
}
.th-break td {
  padding: 4px 2px;
  border-top: 1px solid var(--line);
}
.th-break td:last-child {
  text-align: right;
  font-family: Outfit, sans-serif;
  font-weight: 800;
  color: var(--go);
}
.th-break td.neg {
  color: var(--hot);
}
.th-rankform {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.th-rankform input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0e131a;
  color: var(--ink);
  padding: 0 12px;
  font-size: 15px;
}
.th-rankform .th-btn {
  flex: 0 0 auto;
  padding: 0 14px;
}
.th-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 30px);
  background: rgba(12, 16, 22, 0.96);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  max-width: min(92vw, 520px);
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 60;
}
.th-toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}
.th-top > .today-mute-btn,
.th-hud > .today-mute-btn {
  position: static;
  flex: 0 0 auto;
}
#tduel-invite {
  display: none !important;
}

/* 휴대폰 */
@media (max-width: 640px) {
  .th-bar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .th-bar b {
    font-size: 13.5px;
  }
  .th-game {
    padding: 4px 8px calc(6px + env(safe-area-inset-bottom));
    gap: 5px;
  }
  .th-ph .nm {
    font-size: 11px;
  }
  .th-ph .ic svg {
    width: 28px;
    height: 28px;
  }
  .th-phases {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .th-ph {
    flex-direction: column;
    gap: 2px;
    text-align: center;
    padding: 4px 2px;
  }
  .th-ph kbd {
    display: none;
  }
  .th-toast {
    bottom: 150px;
  }
}
@media (min-width: 900px) {
  .th-game {
    display: grid;
    grid-template-columns: 1fr 260px;
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "hud hud" "bar bar" "stage dock";
  }
  .th-hud {
    grid-area: hud;
  }
  .th-bar {
    grid-area: bar;
  }
  .th-stage {
    grid-area: stage;
  }
  .th-dock {
    grid-area: dock;
    align-self: start;
  }
  .th-phases {
    grid-template-columns: 1fr;
  }
}
