/* Playito.io exact color tokens & tactile paper-on-thread visual language */
:root {
  --white: #ffffff;
  --ink-950: #0f0d22;
  --ink-900: #16132e;
  --ink-800: #201c40;
  --ink-700: #2c2754;
  --ink-500: #5b5585;
  --ink-400: #7e79a8;
  --ink-300: #a39fc4;
  --ink-200: #cfcae6;
  --paper: #f7f1e3;
  --paper-200: #eae1cc;
  --paper-ink: #4a4570;
  --paper-muted: #6b6590;
  --sun: #f2c746;
  --sun-deep: #b38f25;
  --sun-soft: #3a3115;
  --thread: #e8513a;
  --thread-deep: #b4421f;
  --thread-soft: #ff8a73;
  --jade: #45d39a;
  --water: #4fc3d9;
  --wood: #b07a52;
  --wood-deep: #8a5c3b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--ink-900);
  color: var(--paper);
  font-family: 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
body.no-furigana rt { display: none; }

.shell {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

@media (min-width: 640px) {
  .shell { padding: 0 32px 56px; }
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  gap: 16px;
}

.logo-link {
  display: inline-flex;
  color: var(--paper);
  text-decoration: none;
}

.ito-logo {
  height: 40px;
  width: auto;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-toggle {
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--ink-700);
  background: transparent;
  color: var(--paper);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.pill-toggle:hover { border-color: var(--ink-500); background: var(--ink-800); }
.pill-toggle.active { border-color: var(--sun); color: var(--sun); }
.pill-toggle.danger { border-color: rgba(232, 81, 58, 0.45); color: var(--thread-soft); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-950);
  color: var(--paper);
  border: 1.5px solid var(--thread);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  z-index: 90;
  box-shadow: 0 16px 40px rgba(5, 4, 15, 0.6);
}

/* HOME (Playito 2-col desktop grid) */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 32px;
  padding: 16px 0 40px;
}

@media (min-width: 1024px) {
  .home-grid {
    grid-template-columns: minmax(0, 1fr) 440px;
    column-gap: 56px;
    row-gap: 24px;
    padding-top: 32px;
  }
  .hero-copy { grid-column: 1; grid-row: 1; }
  .home-form-wrap { grid-column: 2; grid-row: 1 / span 2; }
  .hero-thread-art { grid-column: 1; grid-row: 2; }
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  border-radius: 999px;
  border: 1px solid var(--ink-700);
  background: var(--ink-800);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--sun);
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--thread);
}

.hero-heading {
  margin: 0;
  font-family: 'Bricolage Grotesque', 'Noto Sans JP', sans-serif;
  font-size: clamp(38px, 6vw, 68px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--paper);
}

.accent-thread { color: var(--thread); }

.hero-lead {
  margin: 0;
  max-width: 520px;
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink-200);
}

/* Right Form Card */
.play-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-radius: 28px;
  border: 1px solid var(--ink-700);
  background: var(--ink-800);
  padding: 28px;
  box-shadow: 0 30px 80px rgba(5, 4, 15, 0.5);
}

.play-card-head h2 {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.play-card-head p {
  margin: 0;
  font-size: 15px;
  color: var(--ink-300);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-field label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--ink-300);
}

.ink-input {
  height: 54px;
  width: 100%;
  border-radius: 16px;
  border: 2px solid var(--ink-700);
  background: var(--ink-900);
  padding: 0 18px;
  font-size: 17px;
  font-weight: 700;
  color: var(--paper);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.ink-input:focus { border-color: var(--sun); }
.ink-input::placeholder { color: var(--ink-500); font-weight: 500; }

.code-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* Color Swatches (Playito exact 8 colors) */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected {
  border-color: var(--ink-800);
  box-shadow: 0 0 0 2.5px var(--paper);
  transform: scale(1.06);
}

/* Tactile 3D Buttons (Playito signature) */
.btn-3d {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 60px;
  padding: 0 28px;
  border: none;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, filter 0.15s;
  width: 100%;
}
.btn-thread {
  background: var(--thread);
  color: var(--paper);
  box-shadow: 0 5px 0 var(--thread-deep);
}
.btn-thread:hover:not(:disabled) { filter: brightness(1.06); }
.btn-thread:active:not(:disabled) {
  transform: translateY(5px);
  box-shadow: none;
}
.btn-3d:disabled {
  background: var(--ink-700);
  color: var(--ink-400);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-sm-3d {
  height: 46px;
  width: auto;
  padding: 0 22px;
  font-size: 15px;
  border-radius: 14px;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 54px;
  padding: 0 20px;
  border-radius: 16px;
  border: 2px solid var(--paper);
  background: transparent;
  color: var(--paper);
  font-size: 15px;
  font-weight: 800;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.btn-outline:hover:not(:disabled) { background: var(--paper); color: var(--ink-900); }
.btn-outline:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm-out { height: 46px; padding: 0 18px; border-radius: 14px; font-size: 14px; }

.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-400);
}
.or-divider::before, .or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ink-700);
}

.join-row { display: flex; gap: 10px; }
.form-note { margin: 0; font-size: 13px; color: var(--ink-300); line-height: 1.5; }

/* Home Curved Thread Illustration */
.hero-thread-art {
  position: relative;
  height: 230px;
  margin-top: 8px;
}
.hero-curve {
  position: absolute;
  left: -24px;
  top: 0;
  width: calc(100% + 48px);
  height: 76px;
}
.demo-card {
  position: absolute;
  width: 112px;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 14px;
  padding: 16px 10px 12px;
  text-align: center;
  box-shadow: 0 14px 32px rgba(5, 4, 15, 0.45);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.demo-card .pin {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 22px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--wood), var(--wood-deep));
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
}
.demo-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 26px;
  font-weight: 800;
  color: var(--ink-900);
}
.demo-word { font-size: 13px; font-weight: 800; color: var(--paper-ink); }
.demo-card.c1 { left: 4%; top: 28px; transform: rotate(-4deg); }
.demo-card.c2 { left: 28%; top: 46px; transform: rotate(2deg); }
.demo-card.c3 { left: 53%; top: 46px; transform: rotate(-2deg); }
.demo-card.c4 { left: 77%; top: 26px; transform: rotate(4deg); }

@media (max-width: 640px) {
  .hero-thread-art { display: none; }
}

/* ROOM VIEW */
.room-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: 20px;
  padding: 10px 14px;
}
.room-bar-left, .room-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.code-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink-900);
  border: 1.5px dashed var(--ink-500);
  border-radius: 12px;
  padding: 6px 14px;
  color: var(--paper);
  cursor: pointer;
  font-family: inherit;
}
.code-pill:hover { border-color: var(--sun); }
.code-label { font-size: 11px; font-weight: 800; color: var(--ink-400); letter-spacing: 0.08em; }
.code-pill strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  letter-spacing: 0.16em;
  color: var(--sun);
}

.meta-pill {
  background: var(--ink-900);
  border: 1px solid var(--ink-700);
  color: var(--ink-200);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}
.hearts-pill { font-size: 15px; letter-spacing: 2px; }

/* Players Strip */
.players-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.player-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink-800);
  border: 1.5px solid var(--ink-700);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--paper);
}
.player-pill.offline { opacity: 0.4; }
.player-pill.ready { border-color: var(--jade); }
.p-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.p-crown { color: var(--sun); font-size: 12px; }

/* Lobby Card */
.lobby-card {
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: 26px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.lobby-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.lobby-top h2, .section-head h2 { margin: 0 0 4px; font-size: 24px; font-weight: 800; }
.sub { margin: 0; font-size: 14px; color: var(--ink-300); }
.count-pill {
  background: var(--ink-900);
  border: 1px solid var(--ink-700);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 800;
  color: var(--sun);
}

.settings-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.setting-box label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-300);
  margin-bottom: 8px;
}
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  height: 42px;
  border-radius: 12px;
  border: 1.5px solid var(--ink-700);
  background: var(--ink-900);
  color: var(--ink-300);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.seg button.active {
  border-color: var(--sun);
  background: var(--sun-soft);
  color: var(--sun);
}
.seg button:disabled { cursor: default; }

.lobby-cta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
}

/* Theme Picker */
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.theme-paper-card {
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 20px;
  padding: 20px;
  border: 3px solid transparent;
  box-shadow: 0 14px 34px rgba(5, 4, 15, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.14s, border-color 0.15s;
}
.theme-paper-card:hover { transform: translateY(-3px); }
.theme-paper-card.voted { border-color: var(--thread); }
.theme-paper-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.55;
  color: var(--ink-900);
}
.theme-paper-scale {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--paper-muted);
  background: var(--paper-200);
  padding: 6px 10px;
  border-radius: 10px;
}
.theme-paper-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.vote-dots { display: flex; gap: 5px; align-items: center; }
.vote-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--paper); box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }
.pick-btn {
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: var(--thread);
  color: var(--paper);
  font-size: 13px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}

.custom-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.custom-row .ink-input { flex: 1; min-width: 240px; }

/* Active Play & Thread Board */
.active-theme-bar {
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: 22px;
  padding: 18px 22px;
  text-align: center;
  margin-bottom: 16px;
}
.active-theme-title {
  font-family: 'Noto Serif JP', serif;
  font-size: clamp(20px, 3.6vw, 30px);
  font-weight: 900;
  line-height: 1.45;
  color: var(--paper);
  margin-bottom: 10px;
}
.active-theme-scale {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-300);
}
.sc-low strong { color: var(--water); }
.sc-high strong { color: var(--thread-soft); }
.sc-bar {
  flex: 1;
  max-width: 240px;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--water), var(--sun), var(--thread));
}

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  background: rgba(69, 211, 154, 0.14);
  border: 2px solid var(--jade);
  border-radius: 20px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.result-bar.fail {
  background: rgba(232, 81, 58, 0.16);
  border-color: var(--thread);
}
.result-text h2 { margin: 0 0 4px; font-size: 20px; }
.result-text p { margin: 0; font-size: 13px; color: var(--ink-200); }
.result-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* The Thread Board */
.thread-board {
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: 26px;
  padding: 18px 18px 20px;
  margin-bottom: 16px;
}
.thread-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-300);
  margin-bottom: 6px;
}
.thread-progress {
  font-family: 'JetBrains Mono', monospace;
  color: var(--sun);
}

.thread-stage {
  position: relative;
  min-height: 220px;
  padding: 24px 6px 14px;
  overflow-x: auto;
}
.stage-curve {
  position: absolute;
  left: 0;
  top: 12px;
  width: 100%;
  height: 44px;
  pointer-events: none;
}

.thread-cards {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  min-height: 175px;
  padding: 10px 4px 4px;
}
@media (max-width: 720px) {
  .thread-cards { justify-content: flex-start; }
}

.thread-empty {
  width: 100%;
  text-align: center;
  padding: 58px 12px 20px;
  font-size: 14px;
  color: var(--ink-400);
}

/* Hanging Paper Card (with Playito wooden clothespin) */
.ito-card {
  position: relative;
  width: 164px;
  flex: 0 0 164px;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 16px;
  padding: 18px 12px 12px;
  border: 3px solid transparent;
  box-shadow: 0 14px 32px rgba(5, 4, 15, 0.45);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.18s, border-color 0.2s;
}
.ito-card::before {
  content: '';
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 13px;
  height: 24px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--wood), var(--wood-deep));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
.ito-card:nth-child(odd) { transform: rotate(-1.2deg); }
.ito-card:nth-child(even) { transform: rotate(1.2deg); }
.ito-card.dragging { opacity: 0.45; transform: scale(0.95); }
.ito-card.drag-over { border-color: var(--sun); transform: translateY(-6px) rotate(0deg); }
.ito-card.reveal-ok { border-color: var(--jade); transform: rotate(0deg); }
.ito-card.reveal-bad { border-color: var(--thread); background: #FFF0EE; transform: rotate(0deg); }

.card-owner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
}
.card-owner-left {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-900);
}
.card-idx {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--paper-muted);
}

.card-clue {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink-900);
  line-height: 1.4;
  min-height: 46px;
  word-break: break-word;
}

.card-num {
  background: var(--ink-900);
  color: var(--paper);
  border-radius: 10px;
  padding: 7px 0;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 800;
}
.card-num.hidden-num {
  background: var(--paper-200);
  color: var(--paper-muted);
  font-size: 16px;
}
.card-num.ok { background: #149664; color: #fff; }
.card-num.bad { background: var(--thread); color: #fff; }

.card-controls {
  display: flex;
  gap: 5px;
}
.mini-btn {
  flex: 1;
  height: 30px;
  border-radius: 8px;
  border: 1px solid #d7cebc;
  background: var(--paper-200);
  color: var(--ink-900);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.mini-btn:hover:not(:disabled) { background: #dfd4bd; }
.mini-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.mini-btn.undo { flex: 0 0 32px; color: var(--thread-deep); }

.thread-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* My Secret Hand */
.hand-wrap {
  background: var(--ink-950);
  border: 1px solid var(--ink-700);
  border-radius: 22px;
  padding: 18px;
}
.hand-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-300);
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.hand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.hand-card {
  background: var(--paper);
  color: var(--ink-900);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 26px rgba(5, 4, 15, 0.45);
}
.hand-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.secret-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink-900);
}
.secret-meter {
  flex: 1;
  height: 8px;
  background: var(--paper-200);
  border-radius: 99px;
  overflow: hidden;
}
.secret-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--water), var(--sun), var(--thread));
}
.hand-state {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--paper-200);
  color: var(--paper-ink);
}
.hand-state.placed { background: #d6f5e7; color: #0f6b47; }

.hand-input {
  height: 46px;
  width: 100%;
  border-radius: 12px;
  border: 2px solid #dcd2bf;
  background: #fffdf8;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-900);
  font-family: inherit;
  outline: none;
}
.hand-input:focus { border-color: var(--thread); }

.hand-btns { display: flex; gap: 8px; }
.hand-btns .btn-3d { height: 44px; font-size: 14px; border-radius: 12px; box-shadow: 0 4px 0 var(--thread-deep); }

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 80;
}
