@font-face {
  font-family: 'Mushin';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./mushin.woff2") format('woff2');
}

:root {
  --ink: #1a1a2e;
  --paper: #f5f0e8;
  --paper2: #ede8dc;
  --line: #c8c0aa;
  --accent: #e63946;
  --blue: #457b9d;
  --green: #2d6a4f;
  --yellow: #f4a261;
  --text: #2c2c2c;
  --muted: #888070;
}

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

body {
  background: var(--paper);
  color: var(--text);
  font-family: "Mushin", cursive;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 60px;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: repeating-linear-gradient(
    transparent,
    transparent 27px,
    rgba(180, 170, 150, 0.25) 27px,
    rgba(180, 170, 150, 0.25) 28px
  );
  pointer-events: none;
  z-index: 0;
}

header {
  width: 100%;
  background: var(--ink);
  color: var(--paper);
  padding: 18px 24px 16px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  position: relative;
  z-index: 1;
}

header h1 {
  font-size: 2rem;
  letter-spacing: 1px;
  color: var(--yellow);
}

header p {
  font-size: 0.82rem;
  color: rgba(245, 240, 232, 0.55);
  font-weight: 700;
}

.score-pill {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.pill {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 5px;
}

.pill.c {
  background: rgba(45, 106, 79, 0.5);
}

.pill.w {
  background: rgba(230, 57, 70, 0.35);
}

.main {
  width: 75vw;
  height: 90svh;
  padding: 20px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 1;
}

/* ローディング */
.loading-card {
  background: var(--ink);
  color: var(--paper);
  border-radius: 16px;
  padding: 20px 24px;
  text-align: center;
}

.loading-card p {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: rgba(245, 240, 232, 0.7);
}

.progress-wrap {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--yellow), var(--accent));
  width: 0%;
  transition: width 0.3s;
}

/* お題 */
.prompt-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.prompt-box {
  flex: 1;
  background: white;
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 12px 18px;
  box-shadow: 4px 4px 0 var(--ink);
  position: relative;
}

.prompt-box .tag {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.prompt-box .word {
  font-size: 2.2rem;
  color: var(--accent);
  line-height: 1.1;
  margin-top: 2px;
}

/* タイマー */
.timer-circle {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  position: relative;
}

.timer-circle svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.timer-circle .bg {
  fill: none;
  stroke: var(--paper2);
  stroke-width: 6;
}

.timer-circle .fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 163;
  stroke-dashoffset: 0;
  transition:
    stroke-dashoffset 1s linear,
    stroke 0.5s;
}

.timer-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--ink);
}

.canvas-wrap {
  position: relative;
  border: 3px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 6px 6px 0 var(--ink);
  cursor: crosshair;
  touch-action: none;
  background: white;
}

canvas {
  display: block;
  width: 100%;
  background: white;
}

.confidence-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(26, 26, 46, 0.88);
  backdrop-filter: blur(6px);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.conf-row {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateX(-6px);
  transition:
    opacity 0.3s,
    transform 0.3s;
}

.conf-row.visible {
  opacity: 1;
  transform: none;
}

.conf-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: rgba(245, 240, 232, 0.6);
  width: 70px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conf-label.match {
  color: #7be8c0;
}

.conf-bar-wrap {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.conf-bar {
  height: 100%;
  border-radius: 999px;
  background: rgba(245, 240, 232, 0.3);
  transition: width 0.35s ease;
}

.conf-bar.match {
  background: linear-gradient(90deg, #2d6a4f, #7be8c0);
}

.conf-pct {
  font-size: 0.75rem;
  font-weight: 800;
  color: rgba(245, 240, 232, 0.5);
  width: 34px;
  text-align: right;
  flex-shrink: 0;
}

.conf-pct.match {
  color: #7be8c0;
}

/* ツールバー */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tbtn {
  background: white;
  border: 2px solid var(--ink);
  border-radius: 10px;
  color: var(--ink);
  font-size: 0.8rem;
  padding: 7px 12px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: all 0.1s;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-family: "Mushin", cursive;
}

.tbtn:hover {
  transform: translate(-1px, -1px);
}

.tbtn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

.tbtn.active {
  background: var(--ink);
  color: var(--paper);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 70px;
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
}

/* 正解演出 */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.result-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.result-card {
  background: white;
  border: 3px solid var(--ink);
  border-radius: 24px;
  padding: 36px 40px;
  text-align: center;
  box-shadow: 8px 8px 0 var(--ink);
  max-width: 340px;
  width: 88%;
  transform: scale(0.8) rotate(-2deg);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-overlay.show .result-card {
  transform: scale(1) rotate(0deg);
}

.result-emoji {
  font-size: 4rem;
  display: block;
  margin-bottom: 8px;
}

.result-title {
  font-size: 2.4rem;
  line-height: 1;
  margin-bottom: 8px;
}

.result-title.correct {
  color: var(--green);
}

.result-title.wrong {
  color: var(--accent);
}

.result-detail {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.5;
}

.result-next {
  width: 100%;
  padding: 13px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 12px;
  font-size: 1.3rem;
  font-family: "Mushin", cursive;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

.result-next:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
}
