@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;1,400&family=Outfit:wght@300;400;500&display=swap');

:root {
    --bg-color: #fdfbf7;
    --surface: #f5f1e7;
    --text-main: #3a4b3f;
    --text-light: #839587;
    --accent: #a3b899;
    --accent-hover: #869e7b;  
    --btn-secondary: #e6dfd1;
    --btn-secondary-hover: #d5cbb9;
    --border: #d4ccbd;
    --shadow: 0 8px 25px rgba(58, 75, 63, 0.06);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    padding: 10px;
    background-image: radial-gradient(var(--surface) 1px, transparent 1px);
    background-size: 20px 20px; 
}

.container {
    width: 100%;
    max-width: 700px;
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 30px;
}

header {
    text-align: center;
    margin-top: 15px;
}

header h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.8rem;
    font-weight: 400;
    font-style: italic;
    letter-spacing: 4px;
    color: var(--text-main);
}

.controls-panel {
    background-color: var(--surface);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
    border: 1px solid #efeae0;
}

.buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

input[type="file"] {
    display: none;
}

.btn {
    padding: 10px 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 400;
    transition: all 0.3s ease;
    text-align: center;
    user-select: none;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--text-main);
    color: #fdfbf7;
    box-shadow: 0 4px 10px rgba(58, 75, 63, 0.15);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    color: white;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--btn-secondary);
    color: var(--text-main);
}

.btn-secondary:hover:not([disabled]) {
    background-color: var(--btn-secondary-hover);
    transform: translateY(-1px);
}

.btn-icon {
    background-color: var(--surface);
    color: var(--text-main);
    font-size: 1.2rem;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.btn-icon:hover:not([disabled]) {
    background-color: var(--btn-secondary);
    transform: translateY(-1px);
}

.btn[disabled], .btn-icon[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none;
}

/* ツールグループ */
.tools-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border);
}

.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-tool {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 6px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-tool.active {
    background-color: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(163, 184, 153, 0.4);
}

/* スライダー */
.slider-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.slider-label {
    color: var(--text-main);
    min-width: 40px;
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1.1rem;
}

input[type=range] {
    -webkit-appearance: none;
    width: 60%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--text-main);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: var(--border);
    border-radius: 2px;
}

/* スタンプパレット */
.stamp-palette {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

.palette-hint {
    font-size: 0.8rem;
    color: var(--text-light);
}

.stamp-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px;
    max-width: 100%;
}

.stamp-item {
    width: 50px;
    height: 50px;
    object-fit: contain;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: all 0.2s;
    background-color: rgba(255,255,255,0.5);
}

.stamp-item:hover, .stamp-item.selected {
    border-color: var(--text-main);
    transform: scale(1.1);
}

.btn-apply {
    margin-top: 10px;
    padding: 8px 20px;
    font-size: 0.9rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(58, 75, 63, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(58, 75, 63, 0); }
    100% { box-shadow: 0 0 0 0 rgba(58, 75, 63, 0); }
}

/* 操作するスタンプのスタイル */
.draggable-stamp {
    position: absolute;
    width: 150px;
    height: auto;
    touch-action: none;
    user-select: none;
    pointer-events: auto;
    cursor: grab;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
    border: 1px dashed rgba(255,255,255,0.8);
    transform-origin: center;
}
.draggable-stamp:active {
    cursor: grabbing;
    border-color: transparent;
}

/* キャンバスコンテナ */
.canvas-container {
    width: 100%;
    background-color: var(--surface);
    border-radius: 4px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    min-height: 400px;
    position: relative;
    border: 3px double var(--border);
}

#placeholderText {
    position: absolute;
    color: var(--text-light);
    pointer-events: none;
    font-weight: 300;
    letter-spacing: 1px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    font-style: italic;
}

/* キャンバスをピッタリ覆うラッパー */
.canvas-wrapper {
    position: relative;
    display: inline-block;
}

canvas {
    display: block;
    max-width: 100%;
    max-height: 65vh;
    width: auto;
    height: auto;
    cursor: crosshair;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#stampOverlay {
    position: absolute;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    pointer-events: none; 
    overflow: hidden;
}
