/* ============================================
   Romi リバーシ - style.css
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  color: #1b1b1b;
  background-color: #f8f6ff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

ul { list-style: none; }
a { text-decoration: none; color: inherit; }
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}
img { max-width: 100%; height: auto; }

/* --- Animations --- */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes flipStone {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(90deg);
  }
  100% {
    transform: rotateY(180deg);
  }
}

@keyframes placeStone {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes bubbleIn {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(8px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes thinkingDots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* --- Screen System --- */
.p-reversi {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.p-reversi.is-active {
  display: block;
  animation: fadeSlideIn 0.5s cubic-bezier(0.215, 0.61, 0.355, 1) both;
}

.p-reversi__inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

/* ============================================
   START SCREEN
   ============================================ */
.p-reversi__start-hero {
  text-align: center;
  margin-bottom: 40px;
}

.p-reversi__start-face {
  width: 100px;
  height: 100px;
  margin-bottom: 16px;
  animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.p-reversi__start-title {
  font-size: 26px;
  font-weight: 800;
  color: #0f47b0;
  margin-bottom: 12px;
  line-height: 1.4;
}

.p-reversi__start-desc {
  font-size: 15px;
  color: #4b4f56;
  line-height: 1.8;
}

/* --- Difficulty Selection --- */
.p-reversi__difficulty {
  text-align: center;
}

.p-reversi__difficulty-label {
  font-size: 16px;
  font-weight: 600;
  color: #4b4f56;
  margin-bottom: 20px;
}

.p-reversi__difficulty-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.p-reversi__difficulty-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 340px;
  padding: 18px 24px;
  background-color: #fff;
  border: 2px solid #e0e0e8;
  border-bottom: 4px solid #c8c8d4;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08),
              0 1px 3px rgba(0,0,0,0.1);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              box-shadow 0.2s,
              border-color 0.2s;
  animation: popIn 0.35s cubic-bezier(0.215, 0.61, 0.355, 1) both;
}

.p-reversi__difficulty-btn:nth-child(2) {
  animation-delay: 0.06s;
}
.p-reversi__difficulty-btn:nth-child(3) {
  animation-delay: 0.12s;
}

.p-reversi__difficulty-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15,71,176,0.12),
              0 2px 4px rgba(0,0,0,0.08);
  border-color: #0f47b0;
}

.p-reversi__difficulty-btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.p-reversi__difficulty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.p-reversi__difficulty-name {
  font-size: 18px;
  font-weight: 700;
  color: #1b1b1b;
}

.p-reversi__difficulty-desc {
  font-size: 13px;
  color: #4b4f56;
  margin-left: auto;
}

/* ============================================
   ORDER SELECTION SCREEN
   ============================================ */
.p-reversi__order-hero {
  text-align: center;
  margin-bottom: 36px;
}

.p-reversi__order-face {
  width: 90px;
  height: 90px;
  margin-bottom: 16px;
  animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.p-reversi__order-title {
  font-size: 24px;
  font-weight: 800;
  color: #0f47b0;
  margin-bottom: 10px;
}

.p-reversi__order-desc {
  font-size: 14px;
  color: #4b4f56;
  line-height: 1.8;
}

.p-reversi__order-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.p-reversi__order-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 220px;
  padding: 20px 20px;
  background-color: #fff;
  border: 2px solid #e0e0e8;
  border-bottom: 4px solid #c8c8d4;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08),
              0 1px 3px rgba(0,0,0,0.1);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              box-shadow 0.2s,
              border-color 0.2s;
  animation: popIn 0.35s cubic-bezier(0.215, 0.61, 0.355, 1) both;
}

.p-reversi__order-btn:nth-child(2) {
  animation-delay: 0.06s;
}

.p-reversi__order-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15,71,176,0.12),
              0 2px 4px rgba(0,0,0,0.08);
  border-color: #0f47b0;
}

.p-reversi__order-btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.p-reversi__order-stone {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.p-reversi__order-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.p-reversi__order-name {
  font-size: 16px;
  font-weight: 700;
  color: #1b1b1b;
}

.p-reversi__order-hint {
  font-size: 12px;
  color: #4b4f56;
  margin-top: 2px;
}

.p-reversi__order-back {
  display: block;
  margin: 0 auto;
  font-size: 14px;
  font-weight: 500;
  color: #4b4f56;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 16px;
  transition: color 0.2s;
}

.p-reversi__order-back:hover {
  color: #0f47b0;
}

/* ============================================
   GAME SCREEN
   ============================================ */
.p-reversi--game .p-reversi__inner {
  padding-top: 20px;
  padding-bottom: 20px;
}

/* --- Score Bar --- */
.p-reversi__score-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 10px 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.p-reversi__score-player,
.p-reversi__score-romi {
  display: flex;
  align-items: center;
  gap: 8px;
}

.p-reversi__stone {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

.p-reversi__stone--black {
  background: radial-gradient(circle at 35% 35%, #555, #1b1b1b);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.3);
}

.p-reversi__stone--white {
  background: radial-gradient(circle at 35% 35%, #fff, #ddd);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.1), 0 0 0 1px #ccc;
}

.p-reversi__score-label {
  font-size: 13px;
  font-weight: 600;
  color: #4b4f56;
}

.p-reversi__score-num {
  font-size: 22px;
  font-weight: 800;
  color: #0f47b0;
  min-width: 28px;
  text-align: center;
}

.p-reversi__turn-indicator {
  font-size: 13px;
  font-weight: 700;
  color: #0f47b0;
  padding: 4px 12px;
  background: rgba(15, 71, 176, 0.08);
  border-radius: 20px;
  white-space: nowrap;
}

.p-reversi__turn-indicator.is-romi {
  color: #c22350;
  background: rgba(194, 35, 80, 0.08);
}

/* --- Board --- */
.p-reversi__board-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.p-reversi__board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 1px;
  background-color: #1b1b1b;
  border: 3px solid #1b1b1b;
  border-radius: 4px;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1 / 1;
}

.p-reversi__cell {
  background-color: #2e8b57;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s;
}

.p-reversi__cell:hover {
  background-color: #3a9d68;
}

.p-reversi__cell.is-hint::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

.p-reversi__cell.is-disabled {
  cursor: default;
}

.p-reversi__cell.is-disabled:hover {
  background-color: #2e8b57;
}

/* --- Stones on Board --- */
.p-reversi__cell-stone {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  position: relative;
  transition: transform 0.1s;
}

.p-reversi__cell-stone.is-black {
  background: radial-gradient(circle at 35% 35%, #555, #1b1b1b);
  box-shadow: inset 0 -2px 6px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.3);
}

.p-reversi__cell-stone.is-white {
  background: radial-gradient(circle at 35% 35%, #fff, #ddd);
  box-shadow: inset 0 -2px 6px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.15);
}

.p-reversi__cell-stone.is-placed {
  animation: placeStone 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.p-reversi__cell-stone.is-flipping {
  animation: flipStone 0.4s ease-in-out;
}

/* --- Romi Area --- */
.p-reversi__romi-area {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.p-reversi__romi-face-wrapper {
  flex-shrink: 0;
}

.p-reversi__romi-face {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f0f2ff;
  padding: 4px;
}

.p-reversi__romi-bubble {
  flex: 1;
  position: relative;
  background: #f0f2ff;
  border-radius: 12px;
  padding: 12px 16px;
  min-height: 48px;
  display: flex;
  align-items: center;
}

.p-reversi__romi-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 20px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 10px 6px 0;
  border-color: transparent #f0f2ff transparent transparent;
}

.p-reversi__romi-bubble.is-updated {
  animation: bubbleIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.p-reversi__romi-comment {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
  color: #1b1b1b;
}

/* ============================================
   RESULT SCREEN
   ============================================ */
.p-reversi--result .p-reversi__inner {
  padding-top: 60px;
  text-align: center;
}

.p-reversi__result-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 24px 32px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  margin-bottom: 32px;
}

.p-reversi__result-face {
  width: 100px;
  height: 100px;
  margin-bottom: 16px;
  animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s both;
}

.p-reversi__result-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
  line-height: 1.4;
}

.p-reversi__result-title.is-win {
  color: #0f47b0;
}
.p-reversi__result-title.is-lose {
  color: #c22350;
}
.p-reversi__result-title.is-draw {
  color: #4b4f56;
}

.p-reversi__result-score {
  font-size: 18px;
  font-weight: 700;
  color: #4b4f56;
  margin-bottom: 8px;
}

.p-reversi__result-difficulty {
  font-size: 14px;
  font-weight: 600;
  color: #0f47b0;
  margin-bottom: 20px;
}

.p-reversi__result-comment-area {
  background: #f0f2ff;
  border-radius: 12px;
  padding: 16px 20px;
}

.p-reversi__result-comment {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.7;
  color: #1b1b1b;
}

/* --- Result Actions --- */
.p-reversi__result-actions {
  margin-bottom: 32px;
}

.p-reversi__retry-btn {
  width: 280px;
  height: 56px;
  font-size: 16px;
  font-weight: 700;
  color: #0f47b0;
  background-color: #fff;
  border: 2px solid #0f47b0;
  border-radius: 56px;
  box-shadow: 0 2px 8px rgba(15, 71, 176, 0.12);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              background-color 0.2s,
              color 0.2s;
}

.p-reversi__retry-btn:hover {
  background-color: #0f47b0;
  color: #fff;
  transform: scale(1.05);
}

.p-reversi__retry-btn:active {
  transform: scale(0.97);
}

/* --- Share --- */
.p-reversi__share {
  margin-top: 24px;
}

.p-reversi--start .p-reversi__share {
  margin-top: 48px;
}

.p-reversi__share-label {
  font-size: 14px;
  font-weight: 600;
  color: #4b4f56;
  margin-bottom: 12px;
}

.p-reversi__share-list {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.p-reversi__share-link {
  display: block;
  overflow: hidden;
  text-indent: -9999px;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 100% auto;
  width: 160px;
  height: 32px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
}

@media (any-hover: hover) {
  .p-reversi__share-link:hover {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

.p-reversi__share-link:active {
  transform: scale(0.97);
}

.p-reversi__share-x {
  background-image: url('assets/sns_x_post.png');
}

.p-reversi__share-line {
  background-image: url('assets/sns_line_share.png');
}

.p-reversi__share-facebook {
  background-image: url('assets/sns_facebook_share.png');
}

/* ============================================
   RESPONSIVE (Mobile: <= 767px)
   ============================================ */
@media (max-width: 767px) {
  .p-reversi__inner {
    padding: 24px 16px 40px;
  }

  .p-reversi__start-title {
    font-size: 22px;
  }

  .p-reversi__start-face {
    width: 80px;
    height: 80px;
  }

  .p-reversi__difficulty-btn {
    padding: 14px 18px;
    max-width: 100%;
  }

  .p-reversi__difficulty-name {
    font-size: 16px;
  }

  /* Order screen */
  .p-reversi__order-face {
    width: 72px;
    height: 72px;
  }

  .p-reversi__order-title {
    font-size: 20px;
  }

  .p-reversi__order-buttons {
    flex-direction: column;
    align-items: center;
  }

  .p-reversi__order-btn {
    max-width: 100%;
  }

  /* Game screen */
  .p-reversi--game .p-reversi__inner {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .p-reversi__score-bar {
    padding: 8px 12px;
    margin-bottom: 10px;
  }

  .p-reversi__score-num {
    font-size: 18px;
  }

  .p-reversi__turn-indicator {
    font-size: 11px;
    padding: 3px 8px;
  }

  .p-reversi__board {
    max-width: calc(100vw - 32px);
  }

  .p-reversi__romi-face {
    width: 48px;
    height: 48px;
  }

  .p-reversi__romi-area {
    padding: 10px;
    gap: 8px;
    margin-top: 10px;
  }

  .p-reversi__romi-comment {
    font-size: 13px;
  }

  /* Result */
  .p-reversi--result .p-reversi__inner {
    padding-top: 40px;
  }

  .p-reversi__result-card {
    padding: 32px 20px 24px;
  }

  .p-reversi__result-title {
    font-size: 24px;
  }

  .p-reversi__result-score {
    font-size: 16px;
  }

  .p-reversi__retry-btn {
    width: 240px;
    height: 48px;
    font-size: 15px;
  }

  .p-reversi__share-list {
    flex-wrap: wrap;
    gap: 10px;
  }

  .p-reversi__share-link {
    width: min(40vw, 150px);
    height: min(8vw, 30px);
  }
}

/* ============================================
   PC (>= 768px) Enhancements
   ============================================ */
@media (min-width: 768px) {
  .p-reversi__start-face {
    width: 120px;
    height: 120px;
  }

  .p-reversi__start-title {
    font-size: 30px;
  }

  .p-reversi__board {
    max-width: 400px;
  }

  .p-reversi__romi-face {
    width: 72px;
    height: 72px;
  }
}
