html {
  overflow-x: hidden;
}

body {
  text-align: center;
  font-family: 'Noto Sans JP', sans-serif;
  padding: 0;
  margin: 0;
  background: url("/static/bg/newbackground.jpg") center/cover no-repeat fixed;
  color: #fff;
  overflow-x: hidden;
  min-height: 100svh;
}

main {
  box-sizing: border-box;
}

.login-screen {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  padding: 16px;
}

.login-panel {
  width: min(420px, 90vw);
  background: rgba(14, 20, 31, 0.9);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  text-align: left;
}

.login-panel h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.5rem;
  text-align: center;
}

.login-panel label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.login-panel input {
  width: 100%;
  padding: 10px 14px;
  margin-top: 6px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 16px;
  box-sizing: border-box;
}

.login-panel button {
  width: 100%;
  margin: 8px 0;
}

.login-hint {
  font-size: 0.9rem;
  color: #9cb6ff;
  margin-top: 8px;
}

.login-error {
  min-height: 1.2em;
  margin-top: 8px;
  font-size: 0.95rem;
  color: #ff8a8a;
}

h1, h2 {
  font-weight: 700;
}

video {
  width: min(350px, 100%);
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
}

#fortuneAvatar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  height: 66vh;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  z-index: 0;
}

.fortune-screen {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  color: #f8f4d9;
}

.fortune-overlay {
  position: relative;
  z-index: 10;
  min-height: 100svh;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: flex-end;
  gap: 16px;
  padding: 24px 16px 24px;
  box-sizing: border-box;
}

#holdRecBtn,
#externalHoldRecBtn {
  touch-action: none;        /* 長押しでもスクロールさせない */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: linear-gradient(135deg, #ff8a00, #ff3d7f);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  padding: 14px 26px;
  border-radius: 999px;
  box-shadow: 0 0 18px rgba(255, 138, 0, 0.7);
  animation: pulseGlow 1.8s ease-in-out infinite;
}

.press-talk,
#recordingStatus,
#externalRecordingStatus {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#holdRecBtn:hover,
#externalHoldRecBtn:hover {
  background: linear-gradient(135deg, #ffa733, #ff5c99);
  box-shadow: 0 0 26px rgba(255, 138, 0, 0.9);
}

#holdRecBtn:disabled,
#externalHoldRecBtn:disabled {
  opacity: 0.6;
  box-shadow: none;
  animation: none;
}

@keyframes pulseGlow {
  0%   { box-shadow: 0 0 12px rgba(255, 138, 0, 0.6); transform: scale(1); }
  50%  { box-shadow: 0 0 24px rgba(255, 138, 0, 0.95); transform: scale(1.04); }
  100% { box-shadow: 0 0 12px rgba(255, 138, 0, 0.6); transform: scale(1); }
}

button {
  margin: 10px;
  padding: 10px 20px;
  font-size: 16px;
  line-height: 1.4;
  border-radius: 10px;
  background-color: #663399;
  color: white;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  max-width: 100%;
}

@media (hover: hover) {
  button:hover {
    background-color: #7d47b0;
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }
}

button:active {
  transform: scale(0.97);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2) inset;
  background-color: #5e2c8c;
}

select,
input[type="file"],
input[type="date"],
input[type="time"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 10px 14px;
  font-size: 16px;
  margin: 10px 0;
  border: 1px solid #ccc;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}


select:focus,
input[type="file"]:focus,
input[type="date"]:focus,
input[type="time"]:focus {
  outline: none;
  border-color: #a888ff;
  box-shadow: 0 0 8px rgba(168, 136, 255, 0.7);
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.02);
}


.hidden { 
  display: none; 
  opacity: 0;
  transition: opacity 0.5s ease;
}
.block  { margin-top: 20px; }

.intro-page,
.gift-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px 20px 48px;
}

.intro-page h2,
.gift-page h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.intro-page p,
.gift-page p {
  width: min(680px, 100%);
  margin: 0;
  line-height: 1.7;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
}

.intro-page button,
.gift-page button {
  width: min(320px, 100%);
}

#result {
  white-space: pre-wrap;
  font-size: 22px;
  line-height: 1.1;
  color: #f8f4d9;
  font-family: 'DotGothic16', 'Noto Sans JP', sans-serif;
  letter-spacing: 0.04em;
  min-height: 92px;
  text-align: left;
}

#timerDisplay {
  font-weight: bold;
  font-size: 18px;
  margin-top: 10px;
}

#ticketDisplay {
  margin-top: 20px;
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  color: #006;
  font-weight: bold;
  word-break: break-word;
}

/* === タロット専用 === */
#tarotArea { margin-top: 20px; }

#cardContainer {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.card-image {
  width: 100px;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

/* === カード裏→表フリップ === */
.card-flip   { transition: transform .6s; transform-style: preserve-3d; }
.card-flip.revealed { transform: rotateY(180deg); }
.card-flip img { backface-visibility: hidden; }
.card-wrapper {
  position: relative;
  display: inline-block;
}

.reversed-image {
  transform: rotate(180deg);
}

.reverse-label {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
  pointer-events: none;
  z-index: 1;
}

.screen-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 6vw, 80px);
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100svh;
  padding: 40px 24px;
  box-sizing: border-box;
}

.char-area {
  flex: 1 1 520px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

.char-area video {
  width: min(540px, 100%);
  max-width: 100%;
}

.ui-area {
  background: rgba(255,255,255,0.1);
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
  flex: 1 1 360px;
  width: min(420px, 100%);
  max-width: 100%;
  margin-left: 0;
  box-sizing: border-box;
  text-align: left;
}

.ui-area h2 {
  margin-top: 0;
  text-align: center;
}

.ui-area .block button {
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  display: block;
}

.highlight {
  color: orange;
  font-weight: bold; /* 必要なら強調も */
}

.dialogue-container {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(960px, calc(100vw - 48px));
  z-index: 30;
}

.dialogue-box {
  position: static;
  width: 100%;
  box-sizing: border-box;
  background: rgba(10, 10, 10, 0.88);
  border: 4px solid rgba(248, 244, 217, 0.9);
  border-radius: 18px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55);
  padding: 16px 20px 18px;
  font-family: 'DotGothic16', 'Noto Sans JP', sans-serif;
  color: #f8f4d9;
  cursor: default;
  user-select: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  z-index: 30;
  min-height: 190px;
  max-height: min(50vh, 460px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dialogue-box:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 6px;
}

.dialogue-box:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}

.dialogue-menu {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
  gap: 8px;
  flex-wrap: wrap;
}

.dialogue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.speaker-name {
  font-size: 18px;
  letter-spacing: 0.08em;
}

.speaker-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.menu-button,
.skip-button {
  font-family: 'DotGothic16', 'Noto Sans JP', sans-serif;
  font-size: 14px;
  padding: 6px 12px;
  margin: 0;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(248, 244, 217, 0.7);
  border-radius: 8px;
  color: #f8f4d9;
  cursor: pointer;
}

.skip-button {
  margin-left: auto;
}

.menu-button:hover,
.skip-button:hover {
  background: rgba(255, 255, 255, 0.25);
}

.skip-button {
  display: none;
}

.skip-button.is-visible {
  display: inline-flex;
}

.dialogue-body {
  position: relative;
  display: block;
  margin-top: 0;
  overflow-y: auto;
  padding-right: 6px;
}

.dialogue-body::-webkit-scrollbar {
  width: 6px;
}

.dialogue-body::-webkit-scrollbar-thumb {
  background: rgba(248, 244, 217, 0.35);
  border-radius: 4px;
}

.dialogue-transcript {
  font-size: 13px;
  color: rgba(248, 244, 217, 0.65);
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.dialogue-text-wrap {
  position: relative;
  padding-right: 32px;
  cursor: pointer;
  margin-top: 6px;
}

.dialogue-text {
  max-height: 160px;
  overflow-y: auto;
  padding-right: 8px;
  text-align: left;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(248, 244, 217, 0.4) rgba(0, 0, 0, 0.2);
}

.dialogue-text::-webkit-scrollbar {
  width: 6px;
}

.dialogue-text::-webkit-scrollbar-thumb {
  background: rgba(248, 244, 217, 0.4);
  border-radius: 4px;
}

.dialogue-indicator {
  position: absolute;
  right: 4px;
  bottom: 4px;
  font-size: 20px;
  opacity: 0;
  animation: indicator-hop 1s ease-in-out infinite;
  pointer-events: none;
  color: rgba(248, 244, 217, 0.9);
}

.dialogue-indicator.show {
  opacity: 1;
}

.dialogue-controls {
  display: none;
  flex-direction: column;
  gap: 14px;
  font-size: 14px;
  text-align: left;
  margin-top: 8px;
}

.dialogue-controls button {
  margin: 0;
}

.dialogue-controls .loading {
  justify-content: flex-start;
}

.dialogue-settings {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: rgba(248, 244, 217, 0.75);
}

.tts-toggle.inline {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.tts-download {
  font-size: 13px;
  color: rgba(248, 244, 217, 0.6);
}

.tts-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: inherit;
}

.tts-toggle input {
  transform: scale(1.2);
}

.fortune-module,
#handUploadArea {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  color: rgba(248, 244, 217, 0.9);
}

.fortune-module input,
.fortune-module select,
#handUploadArea input {
  width: 100%;
}

.fortune-module button,
#handUploadArea button {
  width: 100%;
}

.fortune-module p,
#handUploadArea p {
  margin-top: 0;
  margin-bottom: 10px;
}

.hand-camera-stage {
  width: min(100%, 360px);
  margin: 0 auto 12px;
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(4, 4, 10, 0.7);
  border: 1px solid rgba(248, 244, 217, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.hand-camera-preview {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: rgba(4, 4, 10, 0.95);
  border-radius: 0;
  box-shadow: none;
}

.hand-camera-status {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(248, 244, 217, 0.78);
}

.hand-camera-status.is-error {
  color: #ffb3b3;
}

.hand-camera-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hand-file-fallback {
  margin-top: 10px;
}

.dialogue-box.show-controls .dialogue-controls {
  display: flex;
}

.dialogue-box.show-controls .dialogue-text-wrap,
.dialogue-box.show-controls .dialogue-transcript,
.dialogue-box.show-controls .dialogue-indicator {
  display: none;
}

.dialogue-box.show-controls .menu-button {
  background: rgba(248, 244, 217, 0.3);
}

.recommendation-box {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(8, 8, 20, 0.7);
  border: 1px solid rgba(248, 244, 217, 0.2);
  text-align: left;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.recommendation-box.hidden {
  display: none;
}

.recommendation-title {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: rgba(248, 244, 217, 0.75);
}

.recommendation-text {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  color: #f8f4d9;
  font-family: 'DotGothic16', 'Noto Sans JP', sans-serif;
}

.recommendation-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recommendation-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(248, 244, 217, 0.3);
  border-radius: 12px;
  background: rgba(248, 244, 217, 0.08);
  color: #f8f4d9;
  font-size: 16px;
  padding: 10px 14px;
  cursor: pointer;
  font-family: 'DotGothic16', 'Noto Sans JP', sans-serif;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.recommendation-item:hover {
  background: rgba(248, 244, 217, 0.16);
  border-color: rgba(248, 244, 217, 0.6);
}

.recommendation-item:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.history-button {
  min-width: 110px;
}

.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 3, 16, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 80;
}

.history-overlay.hidden {
  display: none;
}

.history-panel {
  width: min(1100px, 96vw);
  height: min(90vh, 820px);
  background: rgba(12, 10, 24, 0.95);
  border: 3px solid rgba(248, 244, 217, 0.35);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 26px;
  border-bottom: 1px solid rgba(248, 244, 217, 0.25);
  gap: 12px;
}

.history-header h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.08em;
}

.history-close-button {
  background: rgba(248, 244, 217, 0.2);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px 26px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
}

.history-entry {
  background: rgba(248, 244, 217, 0.05);
  border: 1px solid rgba(248, 244, 217, 0.15);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.history-block {
  margin-bottom: 14px;
}

.history-block:last-child {
  margin-bottom: 0;
}

.history-block-label {
  font-size: 13px;
  color: rgba(248, 244, 217, 0.75);
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

.history-block.user .history-block-label {
  color: #a6d6ff;
}

.history-block.user .history-block-text {
  color: #cde7ff;
}

.history-block-text {
  font-size: 16px;
  line-height: 1.8;
  color: #f8f4d9;
  word-break: break-word;
}

.history-empty {
  width: 100%;
  text-align: center;
  margin: 0;
  color: rgba(248, 244, 217, 0.7);
  font-size: 16px;
}

.history-overlay .history-list::-webkit-scrollbar {
  width: 8px;
}

.history-overlay .history-list::-webkit-scrollbar-thumb {
  background: rgba(248, 244, 217, 0.3);
  border-radius: 4px;
}

.external-controls {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-family: 'DotGothic16', 'Noto Sans JP', sans-serif;
  z-index: 40;
}

.external-left {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 220px;
}

.external-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 220px;
}

.external-right #timerDisplay {
  margin: 0;
  color: #ffde59;
  font-size: 18px;
}

.external-buttons {
  display: flex;
  gap: 6px;
}

.external-buttons button {
  padding: 6px 12px;
  font-size: 13px;
  min-width: 110px;
}

.press-talk {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
}

.press-talk button {
  padding: 8px 14px;
  font-size: 14px;
  background: rgba(248, 244, 217, 0.2);
  border: 1px solid rgba(248, 244, 217, 0.6);
  color: #f8f4d9;
}

.press-talk span {
  font-size: 14px;
  color: rgba(248, 244, 217, 0.75);
}

.primary-action {
  background: rgba(248, 244, 217, 0.8);
  color: #2b1a32;
  border: 1px solid rgba(248, 244, 217, 0.9);
}

.primary-action:hover {
  background: rgba(248, 244, 217, 1);
}

.secondary-action {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(248, 244, 217, 0.4);
  color: #f8f4d9;
}

.secondary-action:hover {
  background: rgba(0, 0, 0, 0.6);
}

@media (max-width: 1024px) {
  body {
    background-attachment: scroll;
  }

  .screen-layout {
    flex-direction: column;
    justify-content: flex-start;
    min-height: 100svh;
    padding: 28px 18px 36px;
  }

  .char-area,
  .ui-area {
    width: min(680px, 100%);
    flex: none;
  }

  .dialogue-container {
    position: static;
    width: 100%;
    max-width: none;
    right: auto;
    left: auto;
    bottom: auto;
    transform: none;
  }

  .dialogue-box {
    width: 100%;
    max-width: none;
    max-height: none;
    min-height: 0;
  }

  .fortune-overlay {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 14px;
    padding: 30vh 16px 20px;
  }

  .external-controls {
    position: static;
    width: 100%;
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
  }

  .external-left,
  .external-right {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .intro-page,
  .gift-page {
    padding: 24px 16px 36px;
  }

  .screen-layout {
    padding: 24px 16px 32px;
  }

  .ui-area {
    padding: 18px 16px;
  }

  .intro-page button,
  .gift-page button,
  .ui-area button,
  .external-buttons button,
  #externalHoldRecBtn,
  .fortune-module button,
  #handUploadArea button {
    width: 100%;
    max-width: 100%;
    margin: 8px 0;
  }

  .dialogue-box {
    width: 100%;
    max-height: none;
    padding: 14px 16px 18px;
    border-width: 3px;
  }

  .dialogue-text {
    max-height: 32vh;
    font-size: 18px;
  }

  .dialogue-menu {
    width: 100%;
  }

  .dialogue-menu .menu-button {
    flex: 1 1 0;
  }

  .speaker-group {
    width: 100%;
    align-items: flex-start;
    gap: 8px;
  }

  .external-controls {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    font-size: 14px;
  }

  .external-left {
    justify-content: center;
    width: 100%;
  }

  .external-right {
    align-items: stretch;
    width: 100%;
  }

  .external-buttons {
    width: 100%;
    justify-content: center;
    flex-direction: column;
  }

  .external-buttons button {
    flex: 1;
    min-width: 0;
  }

  .dialogue-settings {
    flex-direction: column;
    align-items: flex-start;
  }

  .hand-camera-actions {
    grid-template-columns: 1fr;
  }

  .press-talk {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  #externalHoldRecBtn {
    width: 100%;
  }

  #cardContainer {
    gap: 8px;
  }

  .card-image {
    width: min(28vw, 92px);
    height: min(45vw, 148px);
  }

  .history-panel {
    width: 100%;
    height: 100svh;
    border-radius: 0;
  }

  .history-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .history-list {
    padding: 16px;
  }
}

@media (max-height: 760px) {
  .intro-page,
  .gift-page {
    gap: 14px;
  }

  #fortuneAvatar {
    height: 56vh;
  }

  .fortune-overlay {
    padding-top: 20vh;
  }

  .dialogue-box {
    max-height: min(56vh, 360px);
  }
}

@keyframes indicator-hop {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

/* ===== ローディング ===== */
.loading { 
  display: none; 
  align-items: center; 
  gap: 10px; 
  margin-top: 10px;
  justify-content: center;
}
.loading.show { display: flex; }

.loading-label {
  display: inline-block;
  min-width: 6em;
  text-align: center;
}

/* ===== 2026-04 Tablet fortune redesign ===== */
.fortune-overlay {
  max-width: 1480px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 20px 18px;
}

.fortune-stage-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: stretch;
}

.fortune-context-panel,
.fortune-side-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fortune-panel-shell,
.recommendation-box,
.dialogue-box,
.fortune-dock {
  background: linear-gradient(180deg, rgba(16, 14, 24, 0.84), rgba(10, 10, 16, 0.92));
  border: 1px solid rgba(248, 244, 217, 0.22);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.fortune-panel-shell {
  border-radius: 24px;
  padding: 18px;
  overflow: hidden;
}

.fortune-side-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.fortune-side-heading.compact {
  margin-bottom: 12px;
}

.fortune-side-heading h2,
.fortune-side-heading h3 {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.2;
}

.fortune-side-heading h3 {
  font-size: 18px;
}

.fortune-panel-eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(248, 244, 217, 0.58);
}

.fortune-mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 215, 111, 0.38);
  background: rgba(255, 203, 94, 0.12);
  color: #ffd966;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.fortune-context-summary {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.7;
  color: rgba(248, 244, 217, 0.76);
}

.fortune-context-preview {
  min-height: 210px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(248, 244, 217, 0.12);
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
}

.fortune-context-empty,
.fortune-context-caption {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: rgba(248, 244, 217, 0.72);
}

.context-hand-preview {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(4, 4, 10, 0.84);
  border: 1px solid rgba(248, 244, 217, 0.14);
}

.context-hand-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.context-tarot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.context-tarot-card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(248, 244, 217, 0.12);
}

.context-tarot-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.context-tarot-card img.is-reversed {
  transform: rotate(180deg);
}

.context-tarot-tag {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 5px 7px;
  border-radius: 999px;
  background: rgba(9, 9, 16, 0.72);
  text-align: center;
  font-size: 11px;
  color: #f8f4d9;
}

.context-tarot-tag.is-muted {
  color: rgba(248, 244, 217, 0.66);
}

.context-meta-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.context-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(248, 244, 217, 0.12);
}

.context-meta-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.context-meta-label {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: rgba(248, 244, 217, 0.66);
}

.context-meta-value {
  font-size: 14px;
  color: #f8f4d9;
}

.fortune-controls-panel {
  flex: 1 1 auto;
  min-height: 0;
}

.fortune-controls-panel .dialogue-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 0;
  height: 100%;
}

.fortune-controls-panel #ttsControls:empty {
  display: none;
}

.fortune-main-stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  padding-top: clamp(120px, 28vh, 280px);
}

.dialogue-container {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  transform: none;
  width: 100%;
}

.dialogue-box {
  max-height: min(55svh, 540px);
  min-height: 300px;
  padding: 22px 24px 20px;
  border-width: 1px;
  border-radius: 28px;
}

.dialogue-menu {
  display: none;
}

.dialogue-header {
  margin-bottom: 10px;
}

.speaker-name {
  font-size: 22px;
}

.dialogue-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.dialogue-transcript {
  min-height: 1.5em;
  font-size: 12px;
  letter-spacing: 0.16em;
}

.dialogue-text-wrap {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0;
  padding-right: 36px;
}

.dialogue-text {
  max-height: 100%;
  min-height: 140px;
  font-size: clamp(21px, 1.75vw, 30px);
  line-height: 1.75;
}

.dialogue-indicator {
  right: 8px;
  bottom: 8px;
}

.loading {
  margin-top: 0;
  justify-content: flex-start;
}

.loading-label {
  min-width: auto;
  text-align: left;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: rgba(248, 244, 217, 0.72);
}

.fortune-side-panel {
  min-height: 0;
}

.fortune-history-panel {
  flex: 1 1 auto;
  min-height: 0;
  background: linear-gradient(180deg, rgba(13, 12, 21, 0.68), rgba(10, 10, 16, 0.8));
}

.history-list--sidebar {
  padding: 0;
  gap: 10px;
}

.history-list--sidebar .history-entry {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(248, 244, 217, 0.1);
  box-shadow: none;
  border-radius: 16px;
}

.history-list--sidebar .history-block {
  margin-bottom: 10px;
}

.history-list--sidebar .history-block-label {
  margin-bottom: 5px;
  font-size: 11px;
}

.history-list--sidebar .history-block-text {
  font-size: 13px;
  line-height: 1.6;
  color: rgba(248, 244, 217, 0.88);
}

.recommendation-box {
  margin-top: 0;
  padding: 18px;
  border-radius: 24px;
}

.recommendation-title {
  margin-bottom: 10px;
}

.recommendation-item {
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.65;
}

.external-controls {
  position: static;
  top: auto;
  right: auto;
  z-index: auto;
}

.fortune-dock {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border-radius: 28px;
}

.external-left {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
}

.external-right {
  flex: 0 0 auto;
  min-width: 260px;
  align-items: flex-end;
  gap: 8px;
}

.external-right #timerDisplay {
  font-size: 20px;
}

.external-buttons {
  gap: 8px;
}

.external-buttons button {
  min-width: 120px;
  padding: 8px 14px;
}

.press-talk {
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.press-talk button {
  min-width: min(420px, 100%);
  padding: 18px 28px;
  font-size: 24px;
}

.press-talk span {
  width: 100%;
  text-align: center;
  font-size: 13px;
}

@media (max-width: 900px) {
  .fortune-overlay {
    max-width: 100%;
    gap: 12px;
    padding: 24vh 16px 18px;
  }

  .fortune-stage-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .fortune-main-stage {
    padding-top: 0;
  }

  .dialogue-menu {
    display: flex;
  }

  .dialogue-box {
    min-height: 220px;
    max-height: none;
    padding: 16px 18px 18px;
    border-radius: 22px;
  }

  .dialogue-text {
    min-height: 0;
    max-height: 34vh;
    font-size: 20px;
  }

  .fortune-context-panel {
    display: none;
  }

  .fortune-context-panel.is-open {
    display: flex;
  }

  .fortune-side-panel {
    order: 3;
  }

  .fortune-history-panel {
    display: none;
  }

  .recommendation-box {
    order: 0;
  }

  .fortune-dock {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
    border-radius: 22px;
  }

  .external-left,
  .external-right {
    width: 100%;
    min-width: 0;
    align-items: stretch;
  }

  .external-right #timerDisplay {
    text-align: center;
  }

  .external-buttons {
    width: 100%;
    justify-content: stretch;
  }

  .external-buttons button {
    flex: 1 1 0;
  }

  .press-talk button {
    width: 100%;
    min-width: 0;
    font-size: 20px;
  }
}

@media (max-width: 640px) {
  .fortune-overlay {
    padding-top: 22vh;
  }

  .fortune-panel-shell,
  .recommendation-box,
  .fortune-dock {
    border-radius: 20px;
  }

  .fortune-context-preview {
    min-height: 160px;
  }

  .context-tarot-grid {
    gap: 8px;
  }

  .external-buttons {
    flex-direction: column;
  }
}

/* ===== 2026-04 viewport containment fix ===== */
.fortune-screen {
  height: 100svh;
  min-height: 100svh;
  overflow: hidden;
}

.fortune-overlay {
  height: 100svh;
  min-height: 100svh;
  overflow: hidden;
  grid-template-rows: minmax(0, 1fr) auto;
}

.fortune-stage-grid {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  grid-template-columns: 250px minmax(0, 1fr) 290px;
}

.fortune-context-panel {
  display: grid;
  grid-template-rows: minmax(220px, 40%) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.fortune-side-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  overflow: hidden;
}

.fortune-panel-shell,
.recommendation-box {
  min-height: 0;
  overflow: hidden;
}

.fortune-context-preview,
.fortune-controls-panel .dialogue-controls,
.history-list--sidebar,
.recommendation-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.fortune-main-stage {
  min-height: 0;
  padding-top: 0;
  overflow: hidden;
}

.dialogue-container {
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: flex-end;
}

.dialogue-box {
  width: min(760px, 100%);
  margin: 0 auto;
  max-height: min(42svh, 420px);
  min-height: 260px;
  overflow: hidden;
}

.dialogue-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.dialogue-text-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.dialogue-text {
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.fortune-dock {
  flex: 0 0 auto;
  min-height: 0;
}

#fortuneAvatar {
  height: 100svh;
  object-fit: cover;
  opacity: 0.92;
}

@media (max-width: 1200px) {
  .fortune-stage-grid {
    grid-template-columns: 230px minmax(0, 1fr) 260px;
  }

  .dialogue-box {
    max-height: min(40svh, 380px);
  }
}

@media (max-width: 900px) {
  .fortune-screen,
  .fortune-overlay {
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
  }

  .fortune-overlay {
    padding: 20vh 14px 14px;
  }

  .fortune-stage-grid {
    height: 100%;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .fortune-main-stage {
    order: 1;
  }

  .fortune-side-panel {
    order: 2;
    display: block;
    min-height: 0;
  }

  .recommendation-box {
    max-height: 22svh;
  }

  .fortune-dock {
    order: 3;
  }

  .dialogue-container {
    align-items: stretch;
  }

  .dialogue-box {
    width: 100%;
    max-height: none;
    min-height: 0;
    height: 100%;
  }

  .dialogue-text {
    max-height: none;
    font-size: 19px;
  }
}

@media (max-width: 640px) {
  .fortune-overlay {
    padding: 18vh 12px 12px;
    gap: 10px;
  }

  .fortune-stage-grid {
    gap: 8px;
  }

  .recommendation-box {
    max-height: 26svh;
    padding: 14px;
  }

  .dialogue-box {
    padding: 14px 14px 16px;
  }

  .dialogue-text {
    font-size: 18px;
    line-height: 1.65;
  }

  .press-talk button {
    padding: 16px 20px;
    font-size: 20px;
  }
}

/* ===== 2026-04 top-stage / bottom-workspace pivot ===== */
.fortune-overlay {
  max-width: none;
  width: 100%;
  padding: 20px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
}

#fortuneAvatar {
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(30vw, 360px);
  height: min(32vh, 250px);
  object-fit: contain;
  object-position: center top;
  background: transparent;
  opacity: 1;
  z-index: 4;
  pointer-events: none;
}

.fortune-workspace {
  grid-row: 2;
  width: 100%;
  min-height: 320px;
  max-height: min(46svh, 430px);
  padding: 18px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(18, 14, 23, 0.9), rgba(11, 10, 15, 0.94));
  border: 1px solid rgba(248, 244, 217, 0.18);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  overflow: hidden;
}

.fortune-stage-grid {
  grid-template-columns: 260px minmax(0, 1fr) 280px;
  gap: 16px;
}

.fortune-context-panel,
.fortune-side-panel,
.fortune-main-stage,
.dialogue-container,
.dialogue-box,
.dialogue-body,
.dialogue-text-wrap,
.fortune-controls-panel,
.fortune-history-panel,
.recommendation-box {
  min-height: 0;
}

.fortune-panel-shell,
.recommendation-box,
.dialogue-box,
.fortune-dock {
  box-shadow: none;
  border-color: rgba(248, 244, 217, 0.14);
}

.fortune-context-panel {
  grid-template-rows: minmax(170px, 1fr) minmax(0, 1fr);
}

.fortune-context-preview {
  min-height: 0;
}

.fortune-controls-panel .dialogue-controls,
.history-list--sidebar,
.recommendation-list,
.fortune-context-preview,
.dialogue-text {
  overscroll-behavior: contain;
}

.fortune-main-stage {
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.dialogue-container {
  width: 100%;
  align-items: stretch;
}

.dialogue-box {
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  padding: 18px 20px;
}

.dialogue-header {
  margin-bottom: 8px;
}

.dialogue-body {
  overflow: hidden;
}

.dialogue-transcript {
  min-height: 1.25em;
}

.dialogue-text-wrap {
  overflow: hidden;
}

.dialogue-text {
  min-height: 0;
  height: 100%;
  max-height: none;
  font-size: clamp(20px, 1.55vw, 28px);
}

.fortune-side-panel {
  grid-template-rows: minmax(0, 1fr) auto;
}

.recommendation-box {
  padding: 14px 16px;
}

.fortune-dock {
  padding: 14px 18px;
  border-radius: 22px;
}

.external-right {
  min-width: 220px;
}

.external-right #timerDisplay {
  font-size: 18px;
}

.press-talk button {
  min-width: min(360px, 100%);
  font-size: 22px;
  padding: 16px 22px;
}

@media (max-width: 1200px) {
  #fortuneAvatar {
    width: min(34vw, 340px);
    height: min(28vh, 220px);
  }

  .fortune-workspace {
    max-height: min(50svh, 470px);
  }

  .fortune-stage-grid {
    grid-template-columns: 230px minmax(0, 1fr) 250px;
  }
}

@media (max-width: 900px) {
  .fortune-overlay {
    padding: 14px;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  #fortuneAvatar {
    top: 10px;
    width: min(58vw, 300px);
    height: min(24vh, 190px);
  }

  .fortune-workspace {
    max-height: min(64svh, 620px);
    min-height: 0;
    padding: 14px;
    border-radius: 24px;
  }

  .fortune-stage-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .fortune-main-stage {
    order: 1;
  }

  .fortune-context-panel {
    order: 2;
    display: none;
    grid-template-rows: minmax(160px, auto) minmax(0, 1fr);
  }

  .fortune-context-panel.is-open {
    display: grid;
  }

  .fortune-side-panel {
    order: 3;
    display: grid;
    grid-template-rows: auto;
  }

  .fortune-history-panel {
    display: none;
  }

  .recommendation-box {
    max-height: 22svh;
  }

  .fortune-dock {
    gap: 12px;
  }
}

@media (max-width: 640px) {
  .fortune-overlay {
    padding: 10px;
  }

  #fortuneAvatar {
    width: min(62vw, 260px);
    height: min(22vh, 160px);
  }

  .fortune-workspace {
    max-height: min(68svh, 640px);
    padding: 12px;
    border-radius: 20px;
  }

  .dialogue-box {
    padding: 14px 14px 16px;
  }

  .dialogue-text {
    font-size: 18px;
    line-height: 1.62;
  }

  .press-talk button {
    font-size: 20px;
    padding: 14px 18px;
  }
}

/* ===== 2026-04 bottom workspace correction ===== */
.fortune-overlay {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100svh;
  min-height: 100svh;
  padding: 18px 18px 20px;
  overflow: hidden;
}

#fortuneAvatar {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(24vw, 280px);
  height: min(22vh, 170px);
  object-fit: contain;
  object-position: center top;
  z-index: 2;
}

.fortune-workspace {
  flex: 0 0 auto;
  width: 100%;
  height: min(44svh, 420px);
  min-height: 320px;
  max-height: min(44svh, 420px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 16px;
  border-radius: 26px;
  overflow: hidden;
}

.fortune-stage-grid {
  height: 100%;
  min-height: 0;
  grid-template-columns: 220px minmax(0, 1fr) 220px;
  gap: 14px;
  overflow: hidden;
}

.fortune-main-stage,
.fortune-side-panel,
.fortune-context-panel,
.dialogue-container {
  height: 100%;
}

.fortune-context-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 0.95fr);
  gap: 14px;
}

.fortune-panel-shell {
  padding: 14px;
  border-radius: 20px;
}

.fortune-side-heading {
  margin-bottom: 10px;
}

.fortune-side-heading h2,
.fortune-side-heading h3 {
  font-size: 16px;
}

.fortune-context-summary,
.fortune-context-empty,
.fortune-context-caption,
.history-list--sidebar .history-block-text,
.recommendation-item {
  font-size: 12px;
}

.fortune-context-preview {
  padding: 10px;
}

.context-tarot-grid {
  gap: 8px;
}

.context-tarot-tag {
  left: 6px;
  right: 6px;
  bottom: 6px;
  font-size: 10px;
  padding: 4px 5px;
}

.dialogue-box {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  padding: 16px 18px;
  border-radius: 24px;
}

.dialogue-header {
  margin-bottom: 6px;
}

.speaker-name {
  font-size: 19px;
}

.dialogue-text {
  font-size: clamp(18px, 1.35vw, 24px);
  line-height: 1.68;
}

.fortune-history-panel {
  min-height: 0;
}

.history-list--sidebar .history-entry {
  padding: 10px 12px;
}

.recommendation-box {
  padding: 12px 14px;
  border-radius: 20px;
}

.recommendation-title {
  margin-bottom: 8px;
  font-size: 12px;
}

.fortune-dock {
  padding: 10px 14px;
  border-radius: 18px;
  gap: 12px;
}

.external-left {
  justify-content: center;
}

.external-right {
  min-width: 0;
}

.external-right #timerDisplay {
  font-size: 16px;
}

.external-buttons button {
  min-width: 104px;
  padding: 7px 10px;
  font-size: 12px;
}

.press-talk button {
  min-width: min(320px, 100%);
  padding: 14px 18px;
  font-size: 20px;
}

.press-talk span {
  font-size: 12px;
}

@media (max-width: 1200px) {
  #fortuneAvatar {
    width: min(28vw, 250px);
    height: min(20vh, 150px);
  }

  .fortune-workspace {
    height: min(48svh, 450px);
    max-height: min(48svh, 450px);
  }

  .fortune-stage-grid {
    grid-template-columns: 200px minmax(0, 1fr) 200px;
  }
}

@media (max-width: 900px) {
  .fortune-overlay {
    padding: 12px 12px 14px;
  }

  #fortuneAvatar {
    top: 12px;
    width: min(56vw, 250px);
    height: min(20vh, 140px);
  }

  .fortune-workspace {
    height: min(70svh, 640px);
    max-height: min(70svh, 640px);
    min-height: 0;
    padding: 12px;
    border-radius: 22px;
  }

  .fortune-stage-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto auto;
    gap: 10px;
  }

  .fortune-main-stage {
    order: 1;
  }

  .fortune-context-panel {
    order: 2;
    height: auto;
    min-height: 0;
    display: none;
  }

  .fortune-context-panel.is-open {
    display: grid;
    grid-template-rows: minmax(150px, auto) minmax(0, 1fr);
  }

  .fortune-side-panel {
    order: 3;
    height: auto;
  }

  .fortune-history-panel {
    display: none;
  }

  .recommendation-box {
    max-height: 18svh;
  }

  .dialogue-box {
    padding: 14px 16px;
  }
}

@media (max-width: 640px) {
  .fortune-overlay {
    padding: 10px 10px 12px;
  }

  #fortuneAvatar {
    width: min(60vw, 220px);
    height: min(18vh, 120px);
  }

  .fortune-workspace {
    height: min(74svh, 680px);
    max-height: min(74svh, 680px);
    padding: 10px;
    border-radius: 18px;
  }

  .dialogue-text {
    font-size: 17px;
  }

  .external-buttons {
    flex-direction: row;
  }
}

/* ===== 2026-04 workspace grid reset ===== */
.fortune-overlay {
  padding: 18px;
  justify-content: flex-end;
}

#fortuneAvatar {
  top: 56px;
  width: min(16vw, 220px);
  height: min(22vh, 220px);
}

.fortune-workspace {
  height: clamp(360px, 48vh, 520px);
  min-height: 360px;
  max-height: clamp(360px, 48vh, 520px);
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 240px;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "left center right"
    "left dock right";
  column-gap: 16px;
  row-gap: 14px;
  align-items: stretch;
}

.fortune-stage-grid {
  display: contents;
}

.fortune-context-panel {
  grid-area: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  height: 100%;
}

.fortune-main-stage {
  grid-area: center;
  min-height: 0;
  height: 100%;
}

.fortune-side-panel {
  grid-area: right;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
  height: 100%;
}

.fortune-dock {
  grid-area: dock;
  align-self: stretch;
}

.fortune-context-panel .fortune-panel-shell:first-child {
  flex: 1 1 58%;
}

.fortune-context-panel .fortune-panel-shell:last-child {
  flex: 1 1 42%;
}

.fortune-panel-shell {
  padding: 14px;
}

.fortune-main-stage,
.dialogue-container,
.dialogue-box,
.dialogue-body,
.dialogue-text-wrap {
  height: 100%;
}

.dialogue-box {
  padding: 16px 18px;
}

.dialogue-body {
  display: flex;
  flex-direction: column;
}

.dialogue-text-wrap {
  flex: 1 1 auto;
}

.dialogue-text {
  height: 100%;
  font-size: clamp(18px, 1.3vw, 23px);
}

.history-list--sidebar,
.fortune-controls-panel .dialogue-controls,
.fortune-context-preview,
.recommendation-list {
  scrollbar-width: thin;
}

.recommendation-box {
  max-height: 38%;
}

.fortune-dock {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.press-talk {
  justify-content: flex-start;
}

.external-right {
  align-items: flex-end;
}

@media (max-width: 1200px) {
  #fortuneAvatar {
    width: min(18vw, 200px);
    height: min(20vh, 180px);
  }

  .fortune-workspace {
    grid-template-columns: 220px minmax(0, 1fr) 210px;
    height: clamp(360px, 50vh, 520px);
    max-height: clamp(360px, 50vh, 520px);
  }
}

@media (max-width: 900px) {
  #fortuneAvatar {
    top: 16px;
    width: min(52vw, 240px);
    height: min(20vh, 150px);
  }

  .fortune-workspace {
    height: min(72svh, 700px);
    max-height: min(72svh, 700px);
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "center"
      "right"
      "dock";
    gap: 10px;
  }

  .fortune-context-panel {
    grid-area: unset;
    display: none;
    height: auto;
  }

  .fortune-context-panel.is-open {
    display: flex;
  }

  .fortune-side-panel {
    grid-area: right;
    height: auto;
    grid-template-rows: auto;
  }

  .fortune-history-panel {
    display: none;
  }

  .fortune-dock {
    flex-direction: column;
    align-items: stretch;
  }

  .press-talk {
    justify-content: center;
  }
}

/* ===== 2026-04 final tablet landscape layout ===== */
.fortune-overlay {
  height: 100svh;
  min-height: 100svh;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}

#fortuneAvatar {
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: min(17vw, 220px);
  height: min(22vh, 220px);
  object-fit: contain;
  object-position: center top;
  z-index: 2;
}

.fortune-workspace {
  flex: 0 0 auto;
  width: 100%;
  height: clamp(360px, 44vh, 500px);
  min-height: 360px;
  max-height: clamp(360px, 44vh, 500px);
  padding: 16px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(16, 14, 22, 0.88), rgba(10, 10, 15, 0.94));
  border: 1px solid rgba(248, 244, 217, 0.16);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}

.fortune-stage-grid {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 220px;
  gap: 16px;
  align-items: stretch;
}

.fortune-context-panel,
.fortune-main-stage,
.fortune-side-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.fortune-context-panel {
  display: block;
}

.fortune-context-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(110px, 1fr) auto minmax(0, 1.05fr);
  gap: 10px;
}

.fortune-context-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(248, 244, 217, 0.16), transparent);
}

.fortune-panel-shell {
  padding: 14px;
  border-radius: 20px;
}

.fortune-side-heading {
  margin-bottom: 0;
}

.fortune-side-heading h2,
.fortune-side-heading h3 {
  margin-top: 2px;
  font-size: 16px;
}

.fortune-panel-eyebrow {
  font-size: 10px;
  letter-spacing: 0.2em;
}

.fortune-mode-badge {
  min-width: 74px;
  padding: 6px 10px;
  font-size: 12px;
}

.fortune-context-summary {
  margin: 0;
  font-size: 12px;
  line-height: 1.65;
}

.fortune-context-preview {
  min-height: 0;
  padding: 10px;
  border-radius: 16px;
  overflow-y: auto;
}

.fortune-context-empty,
.fortune-context-caption,
.context-meta-label,
.context-meta-value,
.history-list--sidebar .history-block-text,
.recommendation-item {
  font-size: 12px;
}

.context-tarot-grid {
  gap: 8px;
}

.context-tarot-card {
  border-radius: 10px;
}

.context-tarot-tag {
  left: 5px;
  right: 5px;
  bottom: 5px;
  font-size: 9px;
  padding: 4px 5px;
}

.fortune-controls-panel .dialogue-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 0;
  overflow-y: auto;
}

.fortune-controls-panel .fortune-module,
.fortune-controls-panel #handUploadArea {
  padding: 12px;
}

.fortune-controls-panel .fortune-module p,
.fortune-controls-panel #handUploadArea p,
.fortune-controls-panel .hand-camera-status {
  font-size: 12px;
  line-height: 1.55;
}

.fortune-main-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
}

.dialogue-container {
  position: static;
  width: 100%;
  height: 100%;
  transform: none;
  display: flex;
}

.dialogue-box {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  padding: 16px 18px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
}

.dialogue-menu {
  display: none;
}

.dialogue-header {
  margin-bottom: 8px;
}

.speaker-name {
  font-size: 19px;
}

.dialogue-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

.dialogue-transcript {
  min-height: 1.25em;
  font-size: 12px;
}

.dialogue-text-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.dialogue-text {
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: clamp(18px, 1.28vw, 23px);
  line-height: 1.7;
}

.loading {
  justify-content: flex-start;
  margin-top: 0;
}

.loading-label {
  font-size: 12px;
}

.fortune-side-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
}

.fortune-history-panel {
  min-height: 0;
}

.history-list--sidebar {
  padding: 0;
  overflow-y: auto;
}

.history-list--sidebar .history-entry {
  padding: 10px 12px;
  border-radius: 14px;
}

.history-list--sidebar .history-block-label {
  font-size: 10px;
}

.recommendation-box {
  margin-top: 0;
  padding: 12px 14px;
  border-radius: 18px;
  max-height: 38%;
}

.recommendation-title {
  margin-bottom: 8px;
  font-size: 11px;
}

.recommendation-list {
  overflow-y: auto;
}

.recommendation-item {
  padding: 10px 12px;
  line-height: 1.55;
}

.fortune-dock {
  position: static;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
}

.external-left,
.external-right {
  min-width: 0;
}

.external-left {
  flex: 1 1 auto;
  justify-content: flex-start;
}

.external-right {
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 6px;
}

.external-right #timerDisplay {
  font-size: 16px;
}

.external-buttons {
  gap: 8px;
}

.external-buttons button {
  min-width: 100px;
  padding: 7px 10px;
  font-size: 12px;
}

.press-talk {
  width: 100%;
  justify-content: flex-start;
  gap: 8px;
}

.press-talk button {
  min-width: min(320px, 100%);
  padding: 14px 18px;
  font-size: 20px;
}

.press-talk span {
  width: auto;
  text-align: left;
  font-size: 12px;
}

@media (max-width: 1200px) {
  #fortuneAvatar {
    width: min(18vw, 190px);
    height: min(20vh, 170px);
  }

  .fortune-workspace {
    height: clamp(360px, 47vh, 520px);
    max-height: clamp(360px, 47vh, 520px);
  }

  .fortune-stage-grid {
    grid-template-columns: 210px minmax(0, 1fr) 200px;
  }
}

@media (max-width: 900px) {
  .fortune-overlay {
    padding: 12px 12px 14px;
  }

  #fortuneAvatar {
    top: 18px;
    width: min(50vw, 230px);
    height: min(18vh, 140px);
  }

  .fortune-workspace {
    height: min(74svh, 720px);
    max-height: min(74svh, 720px);
    min-height: 0;
    padding: 12px;
  }

  .fortune-stage-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto auto;
    gap: 10px;
  }

  .fortune-context-panel {
    display: none;
    height: auto;
  }

  .fortune-context-panel.is-open {
    display: block;
  }

  .fortune-side-panel {
    height: auto;
    grid-template-rows: auto;
  }

  .fortune-history-panel {
    display: none;
  }

  .dialogue-menu {
    display: flex;
  }

  .fortune-dock {
    flex-direction: column;
    align-items: stretch;
  }

  .external-left {
    justify-content: center;
  }

  .press-talk {
    justify-content: center;
  }

  .press-talk button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .fortune-overlay {
    padding: 10px 10px 12px;
  }

  #fortuneAvatar {
    width: min(56vw, 200px);
    height: min(16vh, 120px);
  }

  .fortune-workspace {
    height: min(76svh, 760px);
    max-height: min(76svh, 760px);
    padding: 10px;
    border-radius: 18px;
  }

  .dialogue-box {
    padding: 14px 14px 16px;
  }

  .dialogue-text {
    font-size: 17px;
    line-height: 1.64;
  }

  .external-buttons {
    flex-direction: row;
  }
}
